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

Method test_ulp

Lib/test/test_math.py:2470–2490  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2468
2469 @requires_IEEE_754
2470 def test_ulp(self):
2471 self.assertEqual(math.ulp(1.0), sys.float_info.epsilon)
2472 # use int ** int rather than float ** int to not rely on pow() accuracy
2473 self.assertEqual(math.ulp(2 ** 52), 1.0)
2474 self.assertEqual(math.ulp(2 ** 53), 2.0)
2475 self.assertEqual(math.ulp(2 ** 64), 4096.0)
2476
2477 # min and max
2478 self.assertEqual(math.ulp(0.0),
2479 sys.float_info.min * sys.float_info.epsilon)
2480 self.assertEqual(math.ulp(FLOAT_MAX),
2481 FLOAT_MAX - math.nextafter(FLOAT_MAX, -INF))
2482
2483 # special cases
2484 self.assertEqual(math.ulp(INF), INF)
2485 self.assertIsNaN(math.ulp(math.nan))
2486
2487 # negative number: ulp(-x) == ulp(x)
2488 for x in (0.0, 1.0, 2 ** 52, 2 ** 64, INF):
2489 with self.subTest(x=x):
2490 self.assertEqual(math.ulp(-x), math.ulp(x))
2491
2492 def test_issue39871(self):
2493 # A SystemError should not be raised if the first arg to atan2(),

Callers

nothing calls this directly

Calls 3

assertIsNaNMethod · 0.95
subTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected