()
| 587 | |
| 588 | |
| 589 | def test_Normalize(): |
| 590 | norm = mcolors.Normalize() |
| 591 | vals = np.arange(-10, 10, 1, dtype=float) |
| 592 | _inverse_tester(norm, vals) |
| 593 | _scalar_tester(norm, vals) |
| 594 | _mask_tester(norm, vals) |
| 595 | |
| 596 | # Handle integer input correctly (don't overflow when computing max-min, |
| 597 | # i.e. 127-(-128) here). |
| 598 | vals = np.array([-128, 127], dtype=np.int8) |
| 599 | norm = mcolors.Normalize(vals.min(), vals.max()) |
| 600 | assert_array_equal(norm(vals), [0, 1]) |
| 601 | |
| 602 | # Don't lose precision on longdoubles (float128 on Linux): |
| 603 | # for array inputs... |
| 604 | vals = np.array([1.2345678901, 9.8765432109], dtype=np.longdouble) |
| 605 | norm = mcolors.Normalize(vals[0], vals[1]) |
| 606 | assert norm(vals).dtype == np.longdouble |
| 607 | assert_array_equal(norm(vals), [0, 1]) |
| 608 | # and for scalar ones. |
| 609 | eps = np.finfo(np.longdouble).resolution |
| 610 | norm = plt.Normalize(1, 1 + 100 * eps) |
| 611 | # This returns exactly 0.5 when longdouble is extended precision (80-bit), |
| 612 | # but only a value close to it when it is quadruple precision (128-bit). |
| 613 | assert_array_almost_equal(norm(1 + 50 * eps), 0.5, decimal=3) |
| 614 | |
| 615 | |
| 616 | def test_FuncNorm(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…