MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_Normalize

Function test_Normalize

lib/matplotlib/tests/test_colors.py:589–613  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

587
588
589def 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
616def test_FuncNorm():

Callers

nothing calls this directly

Calls 6

_inverse_testerFunction · 0.85
_scalar_testerFunction · 0.85
_mask_testerFunction · 0.85
normFunction · 0.85
minMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…