8000 Add tests for Clip of powernorm. · matplotlib/matplotlib@571091b · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 571091b

Browse files
committed
Add tests for Clip of powernorm.
These tests are currently failing and should be fixed by the next commit.
1 parent c98a90d commit 571091b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_colors.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ def test_PowerNorm():
6969
assert_equal(pnorm(a[2]), expected[2])
7070
assert_array_almost_equal(a[1:], pnorm.inverse(pnorm(a))[1:])
7171

72+
# Clip = True
73+
a = np.array([-0.5, 0, 1, 8, 16], dtype=np.float)
74+
expected = [0, 0, 0, 1, 1]
75+
pnorm = mcolors.PowerNorm(2, vmin=2, vmax=8, clip=True)
76+
assert_array_almost_equal(pnorm(a), expected)
77+
assert_equal(pnorm(a[0]), expected[0])
78+
assert_equal(pnorm(a[-1]), expected[-1])
79+
80+
# Clip = True at call time
81+
a = np.array([-0.5, 0, 1, 8, 16], dtype=np.float)
82+
expected = [0, 0, 0, 1, 1]
83+
pnorm = mcolors.PowerNorm(2, vmin=2, vmax=8, clip=False)
84+
assert_array_almost_equal(pnorm(a, clip=True), expected)
85+
assert_equal(pnorm(a[0], clip=True), expected[0])
86+
assert_equal(pnorm(a[-1], clip=True), expected[-1])
87+
7288

7389
def test_Normalize():
7490
norm = mcolors.Normalize()

0 commit comments

Comments
 (0)
0