Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e18af55

Browse files
authored
Merge pull request #10442 from anntzer/filternorm
Make the filternorm prop of Images a boolean rather than a {0,1} scalar.
2 parents 0a57153 + 8e68152 commit e18af55

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5170,9 +5170,9 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51705170
shape : scalars (columns, rows), optional, default: None
51715171
For raw buffer images
51725172
5173-
filternorm : scalar, optional, default: 1
5174-
A parameter for the antigrain image resize filter. From the
5175-
antigrain documentation, if `filternorm` = 1, the filter
5173+
filternorm : bool, optional, default: True
5174+
A parameter for the antigrain image resize filter (see the
5175+
antigrain documentation). If *filternorm* is set, the filter
51765176
normalizes integer values and corrects the rounding errors. It
51775177
doesn't do anything with the source floating point values, it
51785178
corrects only integers according to the rule of 1.0 which means

lib/matplotlib/image.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __init__(self, ax,
188188
norm=None,
189189
interpolation=None,
190190
origin=None,
191-
filternorm=1,
191+
filternorm=True,
192192
filterrad=4.0,
193193
resample=False,
194194
**kwargs
@@ -424,7 +424,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
424424
_interpd_[self.get_interpolation()],
425425
self.get_resample(), 1.0,
426426
self.get_filternorm(),
427-
self.get_filterrad() or 0.0)
427+
self.get_filterrad())
428428

429429
# we are done with A_scaled now, remove from namespace
430430
# to be sure!
@@ -459,7 +459,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
459459
_interpd_[self.get_interpolation()],
460460
True, 1,
461461
self.get_filternorm(),
462-
self.get_filterrad() or 0.0)
462+
self.get_filterrad())
463463
# we are done with the mask, delete from namespace to be sure!
464464
del mask
465465
# Agg updates the out_mask in place. If the pixel has
@@ -492,7 +492,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
492492
_image.resample(
493493
A, output, t, _interpd_[self.get_interpolation()],
494494
self.get_resample(), alpha,
495-
self.get_filternorm(), self.get_filterrad() or 0.0)
495+
self.get_filternorm(), self.get_filterrad())
496496

497497
# at this point output is either a 2D array of normed data
498498
# (of int or float)
@@ -735,20 +735,17 @@ def get_resample(self):
735735

736736
def set_filternorm(self, filternorm):
737737
"""
738-
Set whether the resize filter norms the weights -- see
739-
help for imshow
738+
Set whether the resize filter normalizes the weights.
740739
741-
ACCEPTS: 0 or 1
742-
"""
743-
if filternorm:
744-
self._filternorm = 1
745-
else:
746-
self._filternorm = 0
740+
See help for `~.Axes.imshow`.
747741
742+
.. ACCEPTS: bool
743+
"""
744+
self._filternorm = bool(filternorm)
748745
self.stale = True
749746

750747
def get_filternorm(self):
751-
"""Return the filternorm setting."""
748+
"""Return whether the resize filter normalizes the weights."""
752749
return self._filternorm
753750

754751
def set_filterrad(self, filterrad):

0 commit comments

Comments
 (0)