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

Skip to content

new MatplotlibDeprecationWarning class (against 1.2.x)#1596

Merged
mdboom merged 2 commits intomatplotlib:v1.2.xfrom
ivanov:mpl-deprecation-warnings-1.2.x
Dec 18, 2012
Merged

new MatplotlibDeprecationWarning class (against 1.2.x)#1596
mdboom merged 2 commits intomatplotlib:v1.2.xfrom
ivanov:mpl-deprecation-warnings-1.2.x

Conversation

@ivanov
Copy link
Copy Markdown
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
Copy Markdown
Member

This gets my +1.

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

Comment thread lib/matplotlib/axes.py Outdated
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

NelleV commented Dec 17, 2012

This looks OK from a pep8 point of view

@ivanov
Copy link
Copy Markdown
Member Author

ivanov commented Dec 17, 2012

ok, updated to mplDeprecation everywhere

@dmcdougall
Copy link
Copy Markdown
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