Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5cf2f93

Browse files
committed
MNT: deprecate mlab
.... except for GaussianKDE, which is needed for violinplots
1 parent04c8107 commit5cf2f93

File tree

5 files changed

+54
-1086
lines changed

5 files changed

+54
-1086
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ def acorr(self, x, **kwargs):
19031903
----------
19041904
x : array-like
19051905
1906-
detrend : callable, default:`.mlab.detrend_none` (no detrending)
1906+
detrend : callable, default: no detrending
19071907
A detrending function applied to *x*. It must have the
19081908
signature ::
19091909
@@ -1967,7 +1967,7 @@ def acorr(self, x, **kwargs):
19671967
returnself.xcorr(x,x,**kwargs)
19681968

19691969
@_preprocess_data(replace_names=["x","y"],label_namer="y")
1970-
defxcorr(self,x,y,normed=True,detrend=mlab.detrend_none,
1970+
defxcorr(self,x,y,normed=True,detrend=None,
19711971
usevlines=True,maxlags=10,**kwargs):
19721972
r"""
19731973
Plot the cross correlation between *x* and *y*.
@@ -1980,7 +1980,7 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
19801980
----------
19811981
x, y : array-like of length n
19821982
1983-
detrend : callable, default:`.mlab.detrend_none` (no detrending)
1983+
detrend : callable, default: no detrending
19841984
A detrending function applied to *x* and *y*. It must have the
19851985
signature ::
19861986
@@ -2045,8 +2045,9 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
20452045
ifNx!=len(y):
20462046
raiseValueError('x and y must be equal length')
20472047

2048-
x=detrend(np.asarray(x))
2049-
y=detrend(np.asarray(y))
2048+
ifdetrendisnotNone:
2049+
x=detrend(np.asarray(x))
2050+
y=detrend(np.asarray(y))
20502051

20512052
correls=np.correlate(x,y,mode="full")
20522053

@@ -7016,6 +7017,7 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
70167017

70177018
returnh,xedges,yedges,pc
70187019

7020+
@_api.deprecated("3.6",alternative="scipy.signal.psd and ax.loglog")
70197021
@_preprocess_data(replace_names=["x"])
70207022
@_docstring.dedent_interpd
70217023
defpsd(self,x,NFFT=None,Fs=None,Fc=None,detrend=None,
@@ -7127,6 +7129,7 @@ def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
71277129
else:
71287130
returnpxx,freqs,line
71297131

7132+
@_api.deprecated("3.6",alternative="scipy.signal.csd and ax.plot")
71307133
@_preprocess_data(replace_names=["x","y"],label_namer="y")
71317134
@_docstring.dedent_interpd
71327135
defcsd(self,x,y,NFFT=None,Fs=None,Fc=None,detrend=None,
@@ -7229,6 +7232,9 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None,
72297232
else:
72307233
returnpxy,freqs,line
72317234

7235+
@_api.deprecated(
7236+
"3.6",
7237+
alternative="scipy.signal.spectrogram(mode='magnitude') and ax.loglog")
72327238
@_preprocess_data(replace_names=["x"])
72337239
@_docstring.dedent_interpd
72347240
defmagnitude_spectrum(self,x,Fs=None,Fc=None,window=None,
@@ -7315,6 +7321,9 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None,
73157321

73167322
returnspec,freqs,line
73177323

7324+
@_api.deprecated("3.6",
7325+
alternative="scipy.signal.spectrogram(mode='angle') and "
7326+
"ax.loglog")
73187327
@_preprocess_data(replace_names=["x"])
73197328
@_docstring.dedent_interpd
73207329
defangle_spectrum(self,x,Fs=None,Fc=None,window=None,
@@ -7384,6 +7393,9 @@ def angle_spectrum(self, x, Fs=None, Fc=None, window=None,
73847393

73857394
returnspec,freqs,lines[0]
73867395

7396+
@_api.deprecated("3.6",
7397+
alternative="scipy.signal.spectrogram(mode='phase') and "
7398+
"ax.loglog")
73877399
@_preprocess_data(replace_names=["x"])
73887400
@_docstring.dedent_interpd
73897401
defphase_spectrum(self,x,Fs=None,Fc=None,window=None,
@@ -7453,6 +7465,8 @@ def phase_spectrum(self, x, Fs=None, Fc=None, window=None,
74537465

74547466
returnspec,freqs,lines[0]
74557467

7468+
@_api.deprecated("3.6",alternative="scipy.signal.coherence and "
7469+
"ax.semilogx")
74567470
@_preprocess_data(replace_names=["x","y"])
74577471
@_docstring.dedent_interpd
74587472
defcohere(self,x,y,NFFT=256,Fs=2,Fc=0,detrend=mlab.detrend_none,
@@ -7517,6 +7531,9 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
75177531

75187532
returncxy,freqs
75197533

7534+
@_api.deprecated("3.6",
7535+
alternative="scipy.signal.spectrogram(mode='psd') and "
7536+
"ax.loglog")
75207537
@_preprocess_data(replace_names=["x"])
75217538
@_docstring.dedent_interpd
75227539
defspecgram(self,x,NFFT=None,Fs=None,Fc=None,detrend=None,

‎lib/matplotlib/mlab.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
2-
Numerical Python functions written for compatibility with MATLAB
3-
commands with the same names. Most numerical Python functions can be found in
4-
the `NumPy`_ and `SciPy`_ libraries. What remains here is code for performing
5-
spectral computations and kernel density estimations.
2+
This module is deprecated in favour of modules that can be found in
3+
the `NumPy`_ and `SciPy`_ libraries.
64
75
.. _NumPy: https://numpy.org
86
.. _SciPy: https://www.scipy.org
@@ -58,6 +56,7 @@
5856
frommatplotlibimport_api,_docstring,cbook
5957

6058

59+
@_api.deprecated("3.6",alternative="np.hanning")
6160
defwindow_hanning(x):
6261
"""
6362
Return *x* times the Hanning (or Hann) window of len(*x*).
@@ -69,6 +68,7 @@ def window_hanning(x):
6968
returnnp.hanning(len(x))*x
7069

7170

71+
@_api.deprecated("3.6",alternative="")
7272
defwindow_none(x):
7373
"""
7474
No window function; simply return *x*.
@@ -80,6 +80,7 @@ def window_none(x):
8080
returnx
8181

8282

83+
@_api.deprecated("3.6",alternative="scipy.signal.detrend")
8384
defdetrend(x,key=None,axis=None):
8485
"""
8586
Return *x* with its trend removed.
@@ -129,6 +130,7 @@ def detrend(x, key=None, axis=None):
129130
f"'constant', 'mean', 'linear', or a function")
130131

131132

133+
@_api.deprecated("3.6",alternative="scipy.signal.detrend")
132134
defdetrend_mean(x,axis=None):
133135
"""
134136
Return *x* minus the mean(*x*).
@@ -157,6 +159,7 @@ def detrend_mean(x, axis=None):
157159
returnx-x.mean(axis,keepdims=True)
158160

159161

162+
@_api.deprecated("3.6",alternative="scipy.signal.detrend")
160163
defdetrend_none(x,axis=None):
161164
"""
162165
Return *x*: no detrending.
@@ -179,6 +182,7 @@ def detrend_none(x, axis=None):
179182
returnx
180183

181184

185+
@_api.deprecated("3.6",alternative="scipy.signal.detrend")
182186
defdetrend_linear(y):
183187
"""
184188
Return *x* minus best fit line; 'linear' detrending.
@@ -531,6 +535,7 @@ def _single_spectrum_helper(
531535
MATLAB compatibility.""")
532536

533537

538+
@_api.deprecated("3.6",alternative="scipy.signal.psd")
534539
@_docstring.dedent_interpd
535540
defpsd(x,NFFT=None,Fs=None,detrend=None,window=None,
536541
noverlap=None,pad_to=None,sides=None,scale_by_freq=None):
@@ -587,6 +592,7 @@ def psd(x, NFFT=None, Fs=None, detrend=None, window=None,
587592
returnPxx.real,freqs
588593

589594

595+
@_api.deprecated("3.6",alternative="scipy.signal.csd")
590596
@_docstring.dedent_interpd
591597
defcsd(x,y,NFFT=None,Fs=None,detrend=None,window=None,
592598
noverlap=None,pad_to=None,sides=None,scale_by_freq=None):
@@ -688,7 +694,6 @@ def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None,
688694
Can return the complex spectrum of segments within the signal.
689695
"""
690696

691-
692697
complex_spectrum=functools.partial(_single_spectrum_helper,"complex")
693698
complex_spectrum.__doc__=_single_spectrum_docs.format(
694699
quantity="complex-valued frequency spectrum",
@@ -707,6 +712,7 @@ def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None,
707712
**_docstring.interpd.params)
708713

709714

715+
@_api.deprecated("3.6",alternative="scipy.signal.welch")
710716
@_docstring.dedent_interpd
711717
defspecgram(x,NFFT=None,Fs=None,detrend=None,window=None,
712718
noverlap=None,pad_to=None,sides=None,scale_by_freq=None,
@@ -790,6 +796,7 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
790796
returnspec,freqs,t
791797

792798

799+
@_api.deprecated("3.6",alternative="scipy.signal.coherence")
793800
@_docstring.dedent_interpd
794801
defcohere(x,y,NFFT=256,Fs=2,detrend=detrend_none,window=window_hanning,
795802
noverlap=0,pad_to=None,sides='default',scale_by_freq=None):

‎lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,8 +3005,8 @@ def vlines(
30053005
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
30063006
@_copy_docstring_and_deprecators(Axes.xcorr)
30073007
defxcorr(
3008-
x,y,normed=True,detrend=mlab.detrend_none,usevlines=True,
3009-
maxlags=10,*,data=None,**kwargs):
3008+
x,y,normed=True,detrend=None,usevlines=True,maxlags=10,
3009+
*,data=None,**kwargs):
30103010
returngca().xcorr(
30113011
x,y,normed=normed,detrend=detrend,usevlines=usevlines,
30123012
maxlags=maxlags,

‎lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4725,6 +4725,8 @@ def test_subplot_key_hash():
47254725
assertax.get_subplotspec().get_geometry()== (5,1,0,0)
47264726

47274727

4728+
@pytest.mark.filterwarnings(
4729+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
47284730
@image_comparison(
47294731
["specgram_freqs.png","specgram_freqs_linear.png",
47304732
"specgram_noise.png","specgram_noise_linear.png"],
@@ -4761,6 +4763,8 @@ def test_specgram():
47614763
scale="linear",norm=matplotlib.colors.LogNorm())
47624764

47634765

4766+
@pytest.mark.filterwarnings(
4767+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
47644768
@image_comparison(
47654769
["specgram_magnitude_freqs.png","specgram_magnitude_freqs_linear.png",
47664770
"specgram_magnitude_noise.png","specgram_magnitude_noise_linear.png"],
@@ -4798,6 +4802,8 @@ def test_specgram_magnitude():
47984802
scale="linear",norm=matplotlib.colors.LogNorm())
47994803

48004804

4805+
@pytest.mark.filterwarnings(
4806+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
48014807
@image_comparison(
48024808
["specgram_angle_freqs.png","specgram_phase_freqs.png",
48034809
"specgram_angle_noise.png","specgram_phase_noise.png"],
@@ -4836,13 +4842,17 @@ def test_specgram_angle():
48364842
scale="dB")
48374843

48384844

4845+
@pytest.mark.filterwarnings(
4846+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
48394847
deftest_specgram_fs_none():
48404848
"""Test axes.specgram when Fs is None, should not throw error."""
48414849
spec,freqs,t,im=plt.specgram(np.ones(300),Fs=None,scale='linear')
48424850
xmin,xmax,freq0,freq1=im.get_extent()
48434851
assertxmin==32andxmax==96
48444852

48454853

4854+
@pytest.mark.filterwarnings(
4855+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
48464856
@check_figures_equal(extensions=["png"])
48474857
deftest_specgram_origin_rcparam(fig_test,fig_ref):
48484858
"""Test specgram ignores image.origin rcParam and uses origin 'upper'."""
@@ -4861,6 +4871,8 @@ def test_specgram_origin_rcparam(fig_test, fig_ref):
48614871
fig_test.subplots().specgram(signal)
48624872

48634873

4874+
@pytest.mark.filterwarnings(
4875+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
48644876
deftest_specgram_origin_kwarg():
48654877
"""Ensure passing origin as a kwarg raises a TypeError."""
48664878
t=np.arange(500)
@@ -4870,6 +4882,8 @@ def test_specgram_origin_kwarg():
48704882
plt.specgram(signal,origin='lower')
48714883

48724884

4885+
@pytest.mark.filterwarnings(
4886+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
48734887
@image_comparison(
48744888
["psd_freqs.png","csd_freqs.png","psd_noise.png","csd_noise.png"],
48754889
remove_text=True,tol=0.002)
@@ -4904,6 +4918,8 @@ def test_psd_csd():
49044918
ax.set(xlabel="",ylabel="")
49054919

49064920

4921+
@pytest.mark.filterwarnings(
4922+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
49074923
@image_comparison(
49084924
["magnitude_spectrum_freqs_linear.png",
49094925
"magnitude_spectrum_freqs_dB.png",
@@ -4946,6 +4962,8 @@ def test_spectrum():
49464962
ax.set(xlabel="",ylabel="")
49474963

49484964

4965+
@pytest.mark.filterwarnings(
4966+
'ignore::matplotlib._api.deprecation.MatplotlibDeprecationWarning')
49494967
deftest_psd_csd_edge_cases():
49504968
# Inverted yaxis or fully zero inputs used to throw exceptions.
49514969
axs=plt.figure().subplots(2)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp