MCPcopy Index your code
hub / github.com/RustPython/RustPython / assertCloseAbs

Method assertCloseAbs

Lib/test/test_complex.py:75–85  ·  view source on GitHub ↗

Return true iff floats x and y "are close".

(self, x, y, eps=1e-9)

Source from the content-addressed store, hash-verified

73 unittest.TestCase.assertAlmostEqual(self, a, b)
74
75 def assertCloseAbs(self, x, y, eps=1e-9):
76 """Return true iff floats x and y "are close"."""
77 # put the one with larger magnitude second
78 if abs(x) > abs(y):
79 x, y = y, x
80 if y == 0:
81 return abs(x) < eps
82 if x == 0:
83 return abs(y) < eps
84 # check that relative difference < eps
85 self.assertTrue(abs((x-y)/y) < eps)
86
87 def assertClose(self, x, y, eps=1e-9):
88 """Return true iff complexes x and y "are close"."""

Callers 1

assertCloseMethod · 0.95

Calls 2

assertTrueMethod · 0.80
absFunction · 0.50

Tested by

no test coverage detected