astrowisp.tests.utilities module

Class Inheritance Diagram

Inheritance diagram of FloatTestCase

A collection of general use testing utilities.

class astrowisp.tests.utilities.FloatTestCase(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of astrowisp.tests.utilities.FloatTestCase

Test case involving floating point comparisons.

approx_equal(value_1, value_2)[source]

Return True iff value_1 ~= value_2 to within tolerance.

assertApprox(value_1, value_2, message='')[source]

Assert that the two values are equal to wihin the current tolerance.

Notes

The exact definition is:

|value_1 - value_2| <= tolerange * |value_1 + value_2| * float_info.epsilon

Parameters:
  • value_1 – The first of the two values to compare.

  • value_2 – The second of the two values to compare.

Returns:

True iff the two values are within tolerance of each other.

set_tolerance(tolerance)[source]

Set the tolerance for floating point comparisons.

Parameters:

tolerance – The maximum fractional difference in units of floating point epsilon to allow when comparing two floating point numbers. See assertApprox for more details.

Returns:

None

tolerance = 10.0