Skip to content

Commit 2f30efc

Browse files
committed
MNT : remome mlab.FIFOBuffer
Deprecated in 7634812
1 parent e0fd416 commit 2f30efc

File tree

2 files changed

+5
-97
lines changed

2 files changed

+5
-97
lines changed

doc/api/api_changes/code_removal.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ patheffects.svg
6363
Remove ``testing.image_util.py``
6464
--------------------------------
6565
Contained only a no-longer used port of functionality from PIL
66+
67+
68+
Remove ``mlab.FIFOBuffer``
69+
--------------------------
70+
Not used internally and not part of core mission of mpl.

lib/matplotlib/mlab.py

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,103 +2066,6 @@ def fftsurr(x, detrend=detrend_none, window=window_none):
20662066
return np.fft.ifft(z).real
20672067

20682068

2069-
class FIFOBuffer(object):
2070-
"""
2071-
A FIFO queue to hold incoming *x*, *y* data in a rotating buffer
2072-
using numpy arrays under the hood. It is assumed that you will
2073-
call asarrays much less frequently than you add data to the queue
2074-
-- otherwise another data structure will be faster.
2075-
2076-
This can be used to support plots where data is added from a real
2077-
time feed and the plot object wants to grab data from the buffer
2078-
and plot it to screen less freqeuently than the incoming.
2079-
2080-
If you set the *dataLim* attr to
2081-
:class:`~matplotlib.transforms.BBox` (e.g.,
2082-
:attr:`matplotlib.Axes.dataLim`), the *dataLim* will be updated as
2083-
new data come in.
2084-
2085-
TODO: add a grow method that will extend nmax
2086-
2087-
.. note::
2088-
2089-
mlab seems like the wrong place for this class.
2090-
"""
2091-
@cbook.deprecated('1.3', name='FIFOBuffer', obj_type='class')
2092-
def __init__(self, nmax):
2093-
"""
2094-
Buffer up to *nmax* points.
2095-
"""
2096-
self._xa = np.zeros((nmax,), np.float_)
2097-
self._ya = np.zeros((nmax,), np.float_)
2098-
self._xs = np.zeros((nmax,), np.float_)
2099-
self._ys = np.zeros((nmax,), np.float_)
2100-
self._ind = 0
2101-
self._nmax = nmax
2102-
self.dataLim = None
2103-
self.callbackd = {}
2104-
2105-
def register(self, func, N):
2106-
"""
2107-
Call *func* every time *N* events are passed; *func* signature
2108-
is ``func(fifo)``.
2109-
"""
2110-
self.callbackd.setdefault(N, []).append(func)
2111-
2112-
def add(self, x, y):
2113-
"""
2114-
Add scalar *x* and *y* to the queue.
2115-
"""
2116-
if self.dataLim is not None:
2117-
xy = np.asarray([(x, y)])
2118-
self.dataLim.update_from_data_xy(xy, None)
2119-
2120-
ind = self._ind % self._nmax
2121-
self._xs[ind] = x
2122-
self._ys[ind] = y
2123-
2124-
for N, funcs in six.iteritems(self.callbackd):
2125-
if (self._ind % N) == 0:
2126-
for func in funcs:
2127-
func(self)
2128-
2129-
self._ind += 1
2130-
2131-
def last(self):
2132-
"""
2133-
Get the last *x*, *y* or *None*. *None* if no data set.
2134-
"""
2135-
if self._ind == 0:
2136-
return None, None
2137-
ind = (self._ind-1) % self._nmax
2138-
return self._xs[ind], self._ys[ind]
2139-
2140-
def asarrays(self):
2141-
"""
2142-
Return *x* and *y* as arrays; their length will be the len of
2143-
data added or *nmax*.
2144-
"""
2145-
if self._ind < self._nmax:
2146-
return self._xs[:self._ind], self._ys[:self._ind]
2147-
ind = self._ind % self._nmax
2148-
2149-
self._xa[:self._nmax-ind] = self._xs[ind:]
2150-
self._xa[self._nmax-ind:] = self._xs[:ind]
2151-
self._ya[:self._nmax-ind] = self._ys[ind:]
2152-
self._ya[self._nmax-ind:] = self._ys[:ind]
2153-
2154-
return self._xa, self._ya
2155-
2156-
def update_datalim_to_current(self):
2157-
"""
2158-
Update the *datalim* in the current data in the fifo.
2159-
"""
2160-
if self.dataLim is None:
2161-
raise ValueError('You must first set the dataLim attr')
2162-
x, y = self.asarrays()
2163-
self.dataLim.update_from_data(x, y, True)
2164-
2165-
21662069
def movavg(x, n):
21672070
"""
21682071
Compute the len(*n*) moving average of *x*.

0 commit comments

Comments
 (0)