We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c98a90d + e2c4219 commit a786cb1Copy full SHA for a786cb1
lib/matplotlib/colors.py
@@ -1171,8 +1171,8 @@ def __call__(self, value, clip=None):
1171
res_mask = result.data < 0
1172
if clip:
1173
mask = ma.getmask(result)
1174
- val = ma.array(np.clip(result.filled(vmax), vmin, vmax),
1175
- mask=mask)
+ result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
+ mask=mask)
1176
resdat = result.data
1177
resdat -= vmin
1178
np.power(resdat, gamma, resdat)
lib/matplotlib/tests/test_colors.py
@@ -69,6 +69,22 @@ def test_PowerNorm():
69
assert_equal(pnorm(a[2]), expected[2])
70
assert_array_almost_equal(a[1:], pnorm.inverse(pnorm(a))[1:])
71
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
82
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
88
89
def test_Normalize():
90
norm = mcolors.Normalize()
0 commit comments