Skip to content

Commit

Permalink
fixed lognorm clip behavior
Browse files Browse the repository at this point in the history
added test
  • Loading branch information
Tillsten committed Oct 10, 2012
1 parent bb3ea55 commit adb1be2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/matplotlib/colors.py
Expand Up @@ -953,7 +953,7 @@ def __call__(self, value, clip=None):
else:
if clip:
mask = ma.getmask(result)
val = ma.array(np.clip(result.filled(vmax), vmin, vmax),
result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
mask=mask)
# in-place equivalent of above can be much faster
resdat = result.data
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_colors.py
Expand Up @@ -36,4 +36,13 @@ def test_BoundaryNorm():
ncolors = len(boundaries)
bn = mcolors.BoundaryNorm(boundaries, ncolors)
assert_array_equal(bn(vals), expected)

def test_LogNorm():
"""
LogNorm igornoed clip, now it has the same
behavior as Normalize, e.g. values > vmax are bigger than 1
without clip, with clip they are 1.
"""
ln = mcolors.LogNorm(clip=True, vmax=5)
assert_array_equal(ln([1, 6]), [0, 1.0])

0 comments on commit adb1be2

Please sign in to comment.