Test SymLogNorm behavior
()
| 727 | |
| 728 | |
| 729 | def test_SymLogNorm(): |
| 730 | """ |
| 731 | Test SymLogNorm behavior |
| 732 | """ |
| 733 | norm = mcolors.SymLogNorm(3, vmax=5, linscale=1.2, base=np.e) |
| 734 | vals = np.array([-30, -1, 2, 6], dtype=float) |
| 735 | normed_vals = norm(vals) |
| 736 | expected = [0., 0.53980074, 0.826991, 1.02758204] |
| 737 | assert_array_almost_equal(normed_vals, expected) |
| 738 | _inverse_tester(norm, vals) |
| 739 | _scalar_tester(norm, vals) |
| 740 | _mask_tester(norm, vals) |
| 741 | |
| 742 | # Ensure that specifying vmin returns the same result as above |
| 743 | norm = mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2, base=np.e) |
| 744 | normed_vals = norm(vals) |
| 745 | assert_array_almost_equal(normed_vals, expected) |
| 746 | |
| 747 | # test something more easily checked. |
| 748 | norm = mcolors.SymLogNorm(1, vmin=-np.e**3, vmax=np.e**3, base=np.e) |
| 749 | nn = norm([-np.e**3, -np.e**2, -np.e**1, -1, |
| 750 | 0, 1, np.e**1, np.e**2, np.e**3]) |
| 751 | xx = np.array([0., 0.109123, 0.218246, 0.32737, 0.5, 0.67263, |
| 752 | 0.781754, 0.890877, 1.]) |
| 753 | assert_array_almost_equal(nn, xx) |
| 754 | norm = mcolors.SymLogNorm(1, vmin=-10**3, vmax=10**3, base=10) |
| 755 | nn = norm([-10**3, -10**2, -10**1, -1, |
| 756 | 0, 1, 10**1, 10**2, 10**3]) |
| 757 | xx = np.array([0., 0.121622, 0.243243, 0.364865, 0.5, 0.635135, |
| 758 | 0.756757, 0.878378, 1.]) |
| 759 | assert_array_almost_equal(nn, xx) |
| 760 | |
| 761 | |
| 762 | def test_SymLogNorm_colorbar(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…