Skip to content

Commit ad730d1

Browse files
authored
Merge pull request #9335 from anntzer/figureoptions-fix
FIX: poorly done deprecation in image.py.
2 parents 4ccfccb + 3777136 commit ad730d1

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import re
1717

1818
import matplotlib
19-
from matplotlib import cm, markers, colors as mcolors
19+
from matplotlib import cm, colors as mcolors, markers, image as mimage
2020
import matplotlib.backends.qt_editor.formlayout as formlayout
2121
from matplotlib.backends.qt_compat import QtGui
2222

@@ -165,7 +165,7 @@ def prepare_data(d, init):
165165
('Max. value', high),
166166
('Interpolation',
167167
[image.get_interpolation()]
168-
+ [(name, name) for name in sorted(image.iterpnames)])]
168+
+ [(name, name) for name in sorted(mimage.interpolations_names)])]
169169
images.append([imagedata, label, ""])
170170
# Is there an image displayed?
171171
has_image = bool(images)

lib/matplotlib/image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,18 @@ def _rgb_to_rgba(A):
180180
class _ImageBase(martist.Artist, cm.ScalarMappable):
181181
zorder = 0
182182

183+
@property
183184
@cbook.deprecated("2.1")
184185
def _interpd(self):
185186
return _interpd_
186187

188+
@property
187189
@cbook.deprecated("2.1")
188190
def _interpdr(self):
189191
return {v: k for k, v in six.iteritems(_interpd_)}
190192

191-
@cbook.deprecated("2.1")
193+
@property
194+
@cbook.deprecated("2.1", alternative="mpl.image.interpolation_names")
192195
def iterpnames(self):
193196
return interpolations_names
194197

lib/matplotlib/tests/test_image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,3 +827,11 @@ def test_imshow_float128():
827827
def test_imshow_bool():
828828
fig, ax = plt.subplots()
829829
ax.imshow(np.array([[True, False], [False, True]], dtype=bool))
830+
831+
832+
def test_imshow_deprecated_interd_warn():
833+
im = plt.imshow([[1, 2], [3, np.nan]])
834+
for k in ('_interpd', '_interpdr', 'iterpnames'):
835+
with warnings.catch_warnings(record=True) as warns:
836+
getattr(im, k)
837+
assert len(warns) == 1

0 commit comments

Comments
 (0)