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

Function test_FuncNorm

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

Source from the content-addressed store, hash-verified

614
615
616def test_FuncNorm():
617 def forward(x):
618 return (x**2)
619 def inverse(x):
620 return np.sqrt(x)
621
622 norm = mcolors.FuncNorm((forward, inverse), vmin=0, vmax=10)
623 expected = np.array([0, 0.25, 1])
624 input = np.array([0, 5, 10])
625 assert_array_almost_equal(norm(input), expected)
626 assert_array_almost_equal(norm.inverse(expected), input)
627
628 def forward(x):
629 return np.log10(x)
630 def inverse(x):
631 return 10**x
632 norm = mcolors.FuncNorm((forward, inverse), vmin=0.1, vmax=10)
633 lognorm = mcolors.LogNorm(vmin=0.1, vmax=10)
634 assert_array_almost_equal(norm([0.2, 5, 10]), lognorm([0.2, 5, 10]))
635 # use assert_allclose here for rtol on large numbers
636 np.testing.assert_allclose(norm.inverse([0.2, 5, 10]),
637 lognorm.inverse([0.2, 5, 10]))
638
639
640def test_TwoSlopeNorm_autoscale():

Callers

nothing calls this directly

Calls 2

normFunction · 0.85
inverseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…