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

Skip to content

Commit 97c6864

Browse files
committed
Remove mlab deprecations.
1 parent 986bbfe commit 97c6864

File tree

4 files changed

+10
-413
lines changed

4 files changed

+10
-413
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``matplotlib.mlab``
2+
~~~~~~~~~~~~~~~~~~~
3+
``mlab.apply_window`` and ``mlab.stride_repeat`` have been removed.

doc/users/prev_whats_new/whats_new_1.4.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ Support for detrending and windowing 2D arrays in mlab
114114
Todd Jennings added support for 2D arrays in the
115115
:func:`~matplotlib.mlab.detrend_mean`, :func:`~matplotlib.mlab.detrend_none`,
116116
and :func:`~matplotlib.mlab.detrend`, as well as adding
117-
:func:`~matplotlib.mlab.apply_window` which support windowing 2D arrays.
117+
``matplotlib.mlab.apply_window`` which support windowing 2D arrays.
118118

119119
Support for strides in mlab
120120
```````````````````````````
121-
Todd Jennings added some functions to mlab to make it easier to use numpy
121+
Todd Jennings added some functions to mlab to make it easier to use NumPy
122122
strides to create memory-efficient 2D arrays. This includes
123-
:func:`~matplotlib.mlab.stride_repeat`, which repeats an array to create a 2D
123+
``matplotlib.mlab.stride_repeat``, which repeats an array to create a 2D
124124
array, and :func:`~matplotlib.mlab.stride_windows`, which uses a moving window
125125
to create a 2D array from a 1D array.
126126

lib/matplotlib/mlab.py

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
4646
`stride_windows`
4747
Get all windows in an array in a memory-efficient manner
48-
49-
`stride_repeat`
50-
Repeat an array in a memory-efficient manner
51-
52-
`apply_window`
53-
Apply a window along a given axis
5448
"""
5549

5650
import functools
@@ -85,63 +79,6 @@ def window_none(x):
8579
return x
8680

8781

88-
@cbook.deprecated("3.2")
89-
def apply_window(x, window, axis=0, return_window=None):
90-
"""
91-
Apply the given window to the given 1D or 2D array along the given axis.
92-
93-
Parameters
94-
----------
95-
x : 1D or 2D array or sequence
96-
Array or sequence containing the data.
97-
98-
window : function or array.
99-
Either a function to generate a window or an array with length
100-
*x*.shape[*axis*]
101-
102-
axis : int
103-
The axis over which to do the repetition.
104-
Must be 0 or 1. The default is 0
105-
106-
return_window : bool
107-
If true, also return the 1D values of the window that was applied
108-
"""
109-
x = np.asarray(x)
110-
111-
if x.ndim < 1 or x.ndim > 2:
112-
raise ValueError('only 1D or 2D arrays can be used')
113-
if axis+1 > x.ndim:
114-
raise ValueError('axis(=%s) out of bounds' % axis)
115-
116-
xshape = list(x.shape)
117-
xshapetarg = xshape.pop(axis)
118-
119-
if np.iterable(window):
120-
if len(window) != xshapetarg:
121-
raise ValueError('The len(window) must be the same as the shape '
122-
'of x for the chosen axis')
123-
windowVals = window
124-
else:
125-
windowVals = window(np.ones(xshapetarg, dtype=x.dtype))
126-
127-
if x.ndim == 1:
128-
if return_window:
129-
return windowVals * x, windowVals
130-
else:
131-
return windowVals * x
132-
133-
xshapeother = xshape.pop()
134-
135-
otheraxis = (axis+1) % 2
136-
137-
windowValsRep = stride_repeat(windowVals, xshapeother, axis=otheraxis)
138-
139-
if return_window:
140-
return windowValsRep * x, windowVals
141-
else:
142-
return windowValsRep * x
143-
144-
14582
def detrend(x, key=None, axis=None):
14683
"""
14784
Return x with its trend removed.
@@ -343,62 +280,6 @@ def stride_windows(x, n, noverlap=None, axis=0):
343280
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
344281

345282

346-
@cbook.deprecated("3.2")
347-
def stride_repeat(x, n, axis=0):
348-
"""
349-
Repeat the values in an array in a memory-efficient manner. Array x is
350-
stacked vertically n times.
351-
352-
.. warning::
353-
354-
It is not safe to write to the output array. Multiple
355-
elements may point to the same piece of memory, so
356-
modifying one value may change others.
357-
358-
Parameters
359-
----------
360-
x : 1D array or sequence
361-
Array or sequence containing the data.
362-
363-
n : int
364-
The number of time to repeat the array.
365-
366-
axis : int
367-
The axis along which the data will run.
368-
369-
References
370-
----------
371-
`stackoverflow: Repeat NumPy array without replicating data?
372-
<http://stackoverflow.com/a/5568169>`_
373-
"""
374-
if axis not in [0, 1]:
375-
raise ValueError('axis must be 0 or 1')
376-
x = np.asarray(x)
377-
if x.ndim != 1:
378-
raise ValueError('only 1-dimensional arrays can be used')
379-
380-
if n == 1:
381-
if axis == 0:
382-
return np.atleast_2d(x)
383-
else:
384-
return np.atleast_2d(x).T
385-
if n < 1:
386-
raise ValueError('n cannot be less than 1')
387-
388-
# np.lib.stride_tricks.as_strided easily leads to memory corruption for
389-
# non integer shape and strides, i.e. n. See #3845.
390-
n = int(n)
391-
392-
if axis == 0:
393-
shape = (n, x.size)
394-
strides = (0, x.strides[0])
395-
else:
396-
shape = (x.size, n)
397-
strides = (x.strides[0], 0)
398-
399-
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
400-
401-
402283
def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None,
403284
window=None, noverlap=None, pad_to=None,
404285
sides=None, scale_by_freq=None, mode=None):

0 commit comments

Comments
 (0)