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

Skip to content

new MatplotlibDeprecationWarning class (against 1.2.x) #1596

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 2 commits into from
Dec 18, 2012

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Dec 14, 2012

Here's the promised rebase of #1565 onto the maintenance branch, with some whitespace fixes suggested there squashed into the commit here.

In light of the fact that Python builtin DeprecationWarnings are ignored
by default as of Python 2.7 (see link below), this class was put in to
allow for the signaling of deprecation, but via UserWarnings which are
not ignored by default.

http://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x

Prior to this commit:

In [1]: %pylab

Welcome to pylab, a matplotlib-based Python environment [backend: agg].
For more information, type 'help(pylab)'.

In [2]: mlab.liaupunov([1,2], np.diff)
Out[2]: 0.0

After this commit:

In [1]: %pylab

Welcome to pylab, a matplotlib-based Python environment [backend: agg].
For more information, type 'help(pylab)'.

In [2]: mlab.liaupunov([1,2], np.diff)
/home/pi/.local/lib/python2.7/site-packages/matplotlib/mlab.py:1212:
MatplotlibDeprecationWarning: This does not belong in matplotlib and
will be removed
  mDeprecation) # 2009/06/13
Out[2]: 0.0

In light of the fact that Python builtin DeprecationWarnings are ignored
by default as of Python 2.7 (see link below), this class was put in to
allow for the signaling of deprecation, but via UserWarnings which are
not ignored by default.

http://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x

Prior to this commit:

```
In [1]: %pylab

Welcome to pylab, a matplotlib-based Python environment [backend: agg].
For more information, type 'help(pylab)'.

In [2]: mlab.liaupunov([1,2], np.diff)
Out[2]: 0.0
```

After this commit:
```
In [1]: %pylab

Welcome to pylab, a matplotlib-based Python environment [backend: agg].
For more information, type 'help(pylab)'.

In [2]: mlab.liaupunov([1,2], np.diff)
/home/pi/.local/lib/python2.7/site-packages/matplotlib/mlab.py:1212:
MatplotlibDeprecationWarning: This does not belong in matplotlib and
will be removed
  mDeprecation) # 2009/06/13
Out[2]: 0.0
```
@dmcdougall
Copy link
Member

This gets my +1.

@NelleV Do you see any PEP8 issues that need to be addressed here?

@@ -36,6 +36,7 @@
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
import matplotlib.tri as mtri
from matplotlib import MatplotlibDeprecationWarning as mDeprecation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of renaming the variable here -- it makes it less clear what's happening in the lines below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something a little more verbose? mplDeprecationWarning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does just mplDeprecation seem ok? The reason is that it's either being used in code like warnings.warn("message", mplDeprecationWarning) and we then have the word warn written three times on one line, but there are other places where this class is being raised as an exception, so it's not just being used to warn, but actually to throw an error.

I was using mDeprecation because I thought we have that as a convention for prepending an m for matplotlib internal imports (axes.py, axis.py, collections.py and contour.py utilize this for matplotlib module imports)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but in those cases, the m stands for module, which was the source of my confusion about this, at least. I think mplDeprecation would be fine and is a reasonable compromise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mplDeprecation is fine by me!

@NelleV
Copy link
Member

NelleV commented Dec 17, 2012

This looks OK from a pep8 point of view

@ivanov
Copy link
Member Author

ivanov commented Dec 17, 2012

ok, updated to mplDeprecation everywhere

@dmcdougall
Copy link
Member

@ivanov Good job! +1. I think this should be merged now, and I think we should start time-lining a 1.2.1 release.

mdboom added a commit that referenced this pull request Dec 18, 2012
new MatplotlibDeprecationWarning class (against 1.2.x)
@mdboom mdboom merged commit 6a12658 into matplotlib:v1.2.x Dec 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants