(self)
| 2375 | |
| 2376 | @requires_IEEE_754 |
| 2377 | def test_ulp(self): |
| 2378 | self.assertEqual(math.ulp(1.0), sys.float_info.epsilon) |
| 2379 | # use int ** int rather than float ** int to not rely on pow() accuracy |
| 2380 | self.assertEqual(math.ulp(2 ** 52), 1.0) |
| 2381 | self.assertEqual(math.ulp(2 ** 53), 2.0) |
| 2382 | self.assertEqual(math.ulp(2 ** 64), 4096.0) |
| 2383 | |
| 2384 | # min and max |
| 2385 | self.assertEqual(math.ulp(0.0), |
| 2386 | sys.float_info.min * sys.float_info.epsilon) |
| 2387 | self.assertEqual(math.ulp(FLOAT_MAX), |
| 2388 | FLOAT_MAX - math.nextafter(FLOAT_MAX, -INF)) |
| 2389 | |
| 2390 | # special cases |
| 2391 | self.assertEqual(math.ulp(INF), INF) |
| 2392 | self.assertIsNaN(math.ulp(math.nan)) |
| 2393 | |
| 2394 | # negative number: ulp(-x) == ulp(x) |
| 2395 | for x in (0.0, 1.0, 2 ** 52, 2 ** 64, INF): |
| 2396 | with self.subTest(x=x): |
| 2397 | self.assertEqual(math.ulp(-x), math.ulp(x)) |
| 2398 | |
| 2399 | def test_issue39871(self): |
| 2400 | # A SystemError should not be raised if the first arg to atan2(), |
nothing calls this directly
no test coverage detected