-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Mnt deprecate mlab #22920
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
Mnt deprecate mlab #22920
Conversation
lib/matplotlib/mlab.py
Outdated
@@ -840,6 +846,7 @@ def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning, | |||
return Cxy, f | |||
|
|||
|
|||
@_api.deprecated("3.6", alternative="scipy.stats.gaussian_kde") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this internally for violin plots iirc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I was just abusing CI and waiting for things to fail before figuring what needed to be changed elsewhere. Worst-case if I can't make KDEs work directly from scipy I'd still suggest we deprecate this as a public method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, hold it, do we still not require scipy as a hard requirement? I guess that means violinplots need us to vendor this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK backed out this change. I didn't make this private either because the docs leave it possible to pass a GaussianKDE object to violinplots.
lib/matplotlib/pyplot.py
Outdated
@@ -2900,16 +2895,14 @@ def streamplot( | |||
x, y, u, v, density=1, linewidth=None, color=None, cmap=None, | |||
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, | |||
transform=None, zorder=None, start_points=None, maxlength=4.0, | |||
integration_direction='both', broken_streamlines=True, *, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops, Looks like I deleted it by accident. Thanks for catching....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, hmmm. I'm not doing this - its boilerplate.py. I'm not actually clear what is going on here....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. Is boilerplate executed automatically or manually? (Sorry for my ignorance.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually. This commit I've not executed boilerplate, and it seems better plus or minus the font-finding problem, which I believe is unrelated
29710aa
to
3d0b2e3
Compare
Discussed on call. OK to go ahead with this. Vendor GaussianKDE and make the current version private. @oscargus if you were still interested in pulling this out as a toolbox that would be fine as well, but we will deprecate here. Maybe if the toolbox is set up we can change the deprecation messages to point to it? |
@jklymak I'm interested in a toolbox with related functions, yes. While these may not be the ones I use and focus, it may very much make sense to add them there. I'll see if I can come up with something quite soon, at least before 3.6... Not sure if we should wait with merging this until we can point to it (matplotlib/mpl-signal or something) or if we simply should prepare a new PR later on and merge this when (if) decided. |
I don't think there is a rush for the deprecation if you think you will have something in a couple of months. |
I'm certainly OK with deprecating spectral functions from mlab, but I would much rather not add a dependency on scipy. While conda is mostly always available these days, in the rare cases where it's not and no wheels are available (e.g. shortly after new python releases), compiling scipy can be a huge pain (due to the fortran parts), much worse than numpy and matplotlib. |
Yes, that was the consensus on the call - just vendor GaussianKDE. The other functions that should depend on scipy, but do not, will just be flat out deprecated, and maybe moved to a different toolbox if people really complain about the lack of a |
If we want to have a signal related toolkit it makes the most sense for it to be a stand-alone package so you can apologetically depend on scipy! |
Started a bit on the toolbox: https://github.com/oscargus/mplsignal so can easily move relevant functions there when needed. (I expect to maybe release a first version in a few weeks and may ask to have it move to the mpl organization before that as I expect to move it at some stage anyway,) Btw, the idea is to not depend on scipy there either (even though some functions are customized to fit exactly into some scipy-functions like |
604b2b0
to
ca393ec
Compare
ca393ec
to
beaa1d0
Compare
I'm completely befuddled as to why this PR fails font-name tests. I rebased off master, and I don't see any way I touched font handling. Something weird is going on... |
d804f02
to
78aff43
Compare
I realized that we either should deprecate the corresponding functions in pyplot/Axes as well or make sure that they use the non-deprecated versions directly from numpy (where possible) or scipy (and fail gracefully if it is not installed). I could open a PR using the numpy functions directly if that is the preferred solution (but will not spend time otherwise). Edit: I was a bit too quick here and realize that it is only Edit 2: But considering that the tests are removed, which are really tests for pyplot functions, there is still an issue to consider here. |
We should definitely deprecate those! ...done. |
7b9aad9
to
21a6b93
Compare
21a6b93
to
06cd7c1
Compare
06cd7c1
to
9aea3ed
Compare
What's the status here? Is this dependent on mplsignal being released on PyPI? (It doesn't seem to be there yet.) |
commands with the same names. Most numerical Python functions can be found in | ||
the `NumPy`_ and `SciPy`_ libraries. What remains here is code for performing | ||
spectral computations and kernel density estimations. | ||
This module is deprecated in favour of modules that can be found in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the long-term, will GaussianKDE live in another module? Or will mlab stay around to host it?
I don't think this should wait for a replacement package.
OK, I can do that
It probably should get put somewhere else, but seems a bit cumbersome to move it now. |
Actually thats a pretty huge PITA - test_mlab has >100 tests, most of which now fail due to the deprecation warning.... Surely I don't have to wrap them all in a |
I think(?) you can use a pytestmark (https://docs.pytest.org/en/7.1.x/example/markers.html#marking-whole-classes-or-modules) with a custom warningsfilter mark (https://docs.pytest.org/en/7.1.x/how-to/capture-warnings.html#pytest-mark-filterwarnings, see also https://docs.python.org/3/library/warnings.html#describing-warning-filters for syntax). |
019b0e7
to
4e341cb
Compare
OK, tests marked to filter deprecation warnings. I assume we don't need to wrap the individual calls to allow other deprecation warnings to be caught, so this should be fine. This needs a rebase before merging to undo the files that were removed and then added. |
pytest.ini
Outdated
@@ -1,12 +0,0 @@ | |||
# Because tests can be run from an installed copy, most of our Pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should stay.
lib/matplotlib/tests/test_mlab.py
Outdated
@@ -1,1074 +0,0 @@ | |||
from numpy.testing import (assert_allclose, assert_almost_equal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion was to keep this as well (with a global pytestmark to filter warnings everywhere in the file), but I guess the Axes tests essentially cover what we want too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sorry, I forgot I had to "add" it...
4e341cb
to
5cf2f93
Compare
.... except for GaussianKDE, which is needed for violinplots
5cf2f93
to
41f946e
Compare
lib/matplotlib/mlab.py
Outdated
@@ -69,6 +68,7 @@ def window_hanning(x): | |||
return np.hanning(len(x))*x | |||
|
|||
|
|||
@_api.deprecated("3.6", alternative="") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a no-op? I guess I could say lambda x: x
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternative=""
is the default. You don't have to specify this explicitly.
I'm fine either way: Don't give an alternative (we don't have to specify one). Or use lambda x: x
.
lib/matplotlib/mlab.py
Outdated
@@ -157,6 +159,7 @@ def detrend_mean(x, axis=None): | |||
return x - x.mean(axis, keepdims=True) | |||
|
|||
|
|||
@_api.deprecated("3.6", alternative="scipy.signal.detrend") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't seem to be right alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
df4fe34
to
cb27276
Compare
cb27276
to
59532ae
Compare
This one is a bit annoying to drag from milestone to milestone. I still feel we should deprecate all this, but if we aren't going to do it, then let's close the PR. Thanks! |
... we are about to feature freeze for 3.7 - if we would like this change, now is the time to do it, otherwise, we can close this... |
I should be able to get it into mplsignal and make a first release during the holidays. |
OK, I'll close this as I don't see it getting in before 3.7 is frozen, and I'm not willing to rebase it to 3.8. I think we should not be providing this, but understand if folks want to keep it around. |
PR Summary
These are all somewhat fragile wrappers around functionality that rightly belongs elsewhere in the python scientific stack. There is nothing particular to plotting in these routines, and simply predate widely available scipy.signal and scipy.stats. I guess some one could make a new toolbox, but I'm not sure what would be in it...
Obviously this needs wide agreement before proceeding.
Draft until I can see what fails.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).