Skip to content

Fix poorly done deprecations in image.py. #9335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/qt_editor/figureoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import re

import matplotlib
from matplotlib import cm, markers, colors as mcolors
from matplotlib import cm, colors as mcolors, markers, image as mimage
import matplotlib.backends.qt_editor.formlayout as formlayout
from matplotlib.backends.qt_compat import QtGui

Expand Down Expand Up @@ -165,7 +165,7 @@ def prepare_data(d, init):
('Max. value', high),
('Interpolation',
[image.get_interpolation()]
+ [(name, name) for name in sorted(image.iterpnames)])]
+ [(name, name) for name in sorted(mimage.interpolations_names)])]
images.append([imagedata, label, ""])
# Is there an image displayed?
has_image = bool(images)
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ def _rgb_to_rgba(A):
class _ImageBase(martist.Artist, cm.ScalarMappable):
zorder = 0

@property
@cbook.deprecated("2.1")
def _interpd(self):
return _interpd_

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

@cbook.deprecated("2.1")
@property
@cbook.deprecated("2.1", alternative="mpl.image.interpolation_names")
def iterpnames(self):
return interpolations_names

Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,11 @@ def test_imshow_float128():
def test_imshow_bool():
fig, ax = plt.subplots()
ax.imshow(np.array([[True, False], [False, True]], dtype=bool))


def test_imshow_deprecated_interd_warn():
im = plt.imshow([[1, 2], [3, np.nan]])
for k in ('_interpd', '_interpdr', 'iterpnames'):
with warnings.catch_warnings(record=True) as warns:
getattr(im, k)
assert len(warns) == 1