From d46aefb07baa2a57272773b0d507b9842e05f630 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 9 Oct 2017 11:01:45 -0700 Subject: [PATCH 1/3] Fix poorly done deprecations in image.py. --- lib/matplotlib/backends/qt_editor/figureoptions.py | 4 ++-- lib/matplotlib/image.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/qt_editor/figureoptions.py b/lib/matplotlib/backends/qt_editor/figureoptions.py index af9feaf5e5c6..40572c8bd827 100644 --- a/lib/matplotlib/backends/qt_editor/figureoptions.py +++ b/lib/matplotlib/backends/qt_editor/figureoptions.py @@ -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 @@ -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) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index ea2331cb48a7..551813421bf9 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -180,14 +180,17 @@ 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_)} + @property @cbook.deprecated("2.1") def iterpnames(self): return interpolations_names From 05b5759bfcebfe7802f40ff923b4e16e6841d9c2 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 9 Oct 2017 15:11:54 -0500 Subject: [PATCH 2/3] TST: add test of deprecated properties --- lib/matplotlib/tests/test_image.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 9f99fdc6ec8b..15c148f17cdb 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -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 From 37771365727d6beb8c7fe8166fdad9506a44254c Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 10 Oct 2017 11:02:32 -0700 Subject: [PATCH 3/3] Document alternative to iterpnames. --- lib/matplotlib/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 551813421bf9..6b8477f63018 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -191,7 +191,7 @@ def _interpdr(self): return {v: k for k, v in six.iteritems(_interpd_)} @property - @cbook.deprecated("2.1") + @cbook.deprecated("2.1", alternative="mpl.image.interpolation_names") def iterpnames(self): return interpolations_names pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy