From 45b340b4b3e4a6b70a1bcf018f3d39e8f4abf7e5 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 26 Nov 2012 00:30:13 -0800 Subject: [PATCH 1/4] deprecate undocumented `matplotlib/mpl.py` `matplotlib/mpl.py` is a file which used to get imported via ipython's `%pyplot` interface as module named `mpl`, yet it isn't clear at all what it's role is. Given that in our own code, and in the rest of our python neighborhood, we often do `import matplotlib as mpl`, it's quite a bit confusing to have something with the `mpl` name within matplotlib not be the `matplotlib` module itself. This module was only used in `pylab` interface, where it was simply imported in one line via `from matplotlib import mpl` and never used again. With the exception of mpl.finance, all of the modules in mpl.py were readily available simply via "import matplotlib as mpl". pylab's mpl.finance functionality is retained for backwards compatability. --- CHANGELOG | 4 ++++ lib/matplotlib/mpl.py | 5 +++++ lib/matplotlib/pylab.py | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 19f1e06299fc..0cd6fa685cac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ + +2012-11-26 deprecate matplotlib/mpl.py, which was used only in pylab.py and is + now replaced by the more suitable `import matplotlib as mpl`. - PI + 2012-11-13 Add a symmetric log normalization class to colors.py. Also added some tests for the normalization class. Till Stensitzki diff --git a/lib/matplotlib/mpl.py b/lib/matplotlib/mpl.py index 50f317f101d9..466cf6fcb4c9 100644 --- a/lib/matplotlib/mpl.py +++ b/lib/matplotlib/mpl.py @@ -1,3 +1,8 @@ +import warnings +warnings.warn( + "matplotlib.mpl is deprecated and will be removed in the next release." + "Please use `import matplotlib as mpl` instead", + DeprecationWarning) from matplotlib import artist from matplotlib import axis from matplotlib import axes diff --git a/lib/matplotlib/pylab.py b/lib/matplotlib/pylab.py index 2111d4fa734d..bc7333a51b54 100644 --- a/lib/matplotlib/pylab.py +++ b/lib/matplotlib/pylab.py @@ -219,7 +219,10 @@ from cbook import flatten, is_string_like, exception_to_str, \ silent_list, iterable, dedent -from matplotlib import mpl # pulls in most modules +import matplotlib as mpl +# make mpl.finance module available for backwards compatability, in case folks +# using pylab interface depended on not having to import it +import matplotlib.finance from matplotlib.dates import date2num, num2date,\ datestr2num, strpdate2num, drange,\ From 882f1163bbebea3136bc2bf0df6d2758b7810c5e Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Fri, 14 Dec 2012 13:00:15 -0800 Subject: [PATCH 2/4] move to the new MatplotlibDeprecationWarning --- lib/matplotlib/mpl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/mpl.py b/lib/matplotlib/mpl.py index 466cf6fcb4c9..b1cc1d101b45 100644 --- a/lib/matplotlib/mpl.py +++ b/lib/matplotlib/mpl.py @@ -1,8 +1,8 @@ import warnings +from matplotlib import MatplotlibDeprecationWarning as mDeprecation warnings.warn( "matplotlib.mpl is deprecated and will be removed in the next release." - "Please use `import matplotlib as mpl` instead", - DeprecationWarning) + "Please use `import matplotlib as mpl` instead", mDeprecation) from matplotlib import artist from matplotlib import axis from matplotlib import axes From 845ac07b0221f1ff9c11b85e85f4f8431307d77e Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Fri, 14 Dec 2012 13:31:43 -0800 Subject: [PATCH 3/4] added deprecation note to API changes --- doc/api/api_changes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index 2bd2de115a28..f6b311774f84 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -19,6 +19,9 @@ Changes in 1.3.x :class:`~matplotlib.colorbar.ColorbarBase` allows one to control the shape of colorbar extensions. +* The `~matplotlib.mpl` module is now deprecated. Those who relied on this + module should transition to simply using `import matplotlib as mpl`. + Changes in 1.2.x ================ From 472595391318256216aa3ab2937e6631dfe79265 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Mon, 17 Dec 2012 16:16:46 -0800 Subject: [PATCH 4/4] use mplDeprecation convention --- lib/matplotlib/mpl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/mpl.py b/lib/matplotlib/mpl.py index b1cc1d101b45..969a0dc4b380 100644 --- a/lib/matplotlib/mpl.py +++ b/lib/matplotlib/mpl.py @@ -1,8 +1,8 @@ import warnings -from matplotlib import MatplotlibDeprecationWarning as mDeprecation +from matplotlib import MatplotlibDeprecationWarning as mplDeprecation warnings.warn( "matplotlib.mpl is deprecated and will be removed in the next release." - "Please use `import matplotlib as mpl` instead", mDeprecation) + "Please use `import matplotlib as mpl` instead", mplDeprecation) from matplotlib import artist from matplotlib import axis from matplotlib import axes