class_docstr: Perform approximate comparisons where the expected value is a single number.
class_docstr_tok: ["Perform","approximate","comparisons","where","the","expected","value","is","a","single","number","."]
docstr: Return the tolerance for the comparison.  This could be either an
  absolute tolerance or a relative tolerance, depending on what the user
  specified or which would be larger.
code: def tolerance(self):
      """
      Return the tolerance for the comparison.  This could be either an
      absolute tolerance or a relative tolerance, depending on what the user
      specified or which would be larger.
      """
  
      def set_default(x, default):
          return x if x is not None else default
  
      # Figure out what the absolute tolerance should be.  ``self.abs`` is
      # either None or a value specified by the user.
      absolute_tolerance = set_default(
          self.abs, self.DEFAULT_ABSOLUTE_TOLERANCE
      )
  
      if absolute_tolerance < 0:
          raise ValueError(
              "absolute tolerance can't be negative: {}".format(
                  absolute_tolerance
              )
          )
      if math.isnan(absolute_tolerance):
          raise ValueError("absolute tolerance can't be NaN.")
  
      # If the user specified an absolute tolerance but not a relative one,
      # just return the absolute tolerance.
      if self.rel is None:
          if self.abs is not None:
              return absolute_tolerance
  
      # Figure out what the relative tolerance should be.  ``self.rel`` is
      # either None or a value specified by the user.  This is done after
      # we've made sure the user didn't ask for an absolute tolerance only,
      # because we don't want to raise errors about the relative tolerance if
      # we aren't even going to use it.
      relative_tolerance = set_default(
          self.rel, self.DEFAULT_RELATIVE_TOLERANCE
      ) * abs(self.expected)
  
      if relative_tolerance < 0:
          raise ValueError(
              "relative tolerance can't be negative: {}".format(
                  absolute_tolerance
              )
          )
      if math.isnan(relative_tolerance):
          raise ValueError("relative tolerance can't be NaN.")
  
      # Return the larger of the relative and absolute tolerances.
      return max(relative_tolerance, absolute_tolerance)
  
imports: from __future__ import absolute_import
  import math
  import pprint
  import sys
  import warnings
  from decimal import Decimal
  from numbers import Number
  from more_itertools.more import always_iterable
  from six.moves import filterfalse
  from six.moves import zip
  import _pytest._code
  from _pytest import deprecated
  from _pytest.compat import isclass
  from _pytest.compat import Iterable
  from _pytest.compat import Mapping
  from _pytest.compat import Sized
  from _pytest.compat import STRING_TYPES
  from _pytest.outcomes import fail
label_desc: Use image node_id 3 for calling the ApproxScalar obj's underlying member method code with example usage: obj.tolerance() and returns: max, unknown, absolute_tolerance