8000 MNT : remove second version of Cycler classes · danielballan/matplotlib@74e61e1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74e61e1

Browse files
committed
MNT : remove second version of Cycler classes
1 parent 2355776 commit 74e61e1

File tree

1 file changed

+0
-135
lines changed

1 file changed

+0
-135
lines changed

lib/matplotlib/cycler.py

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -177,138 +177,3 @@ def cycler(label, itr):
177177
itr = list(v[lab] for v in itr.finite_iter())
178178

179179
return Cycler._from_iter(label, itr)
180-
181-
182-
class BaseCycler(object):
183-
"""
184-
Helper base-class to provide composition logic to
185-
`SingleCycler` and `CompoundCycler`.
186-
187-
This class
188-
does not have a `__init__` method which will result
189-
in a usable object.
190-
"""
191-
def __iter__(self):
192-
return cycle(self.finite_iter())
193-
194-
def __add__(self, other):
195-
return CompoundCycler(self, other, zip)
196-
197-
def __mul__(self, other):
198-
return CompoundCycler(self, other, product)
199-
200-
201-
class SingleCycler(BaseCycler):
202-
"""
203-
Class to hold the cycle for a single parameter and handle the
204-
composition.
205-
206-
Parameters
207-
----------
208-
label : str
209-
The name of the property this cycles over
210-
itr : iterable
211-
Finite length iterable of the property values.
212-
"""
213-
def __init__(self, label, itr):
214-
self._itr = itr
215-
self._label = label
216-
217-
def finite_iter(self):
218-
"""
219-
Return a finite iterator over the configurations in
220-
this cycle.
221-
222-
Returns
223-
-------
224-
gen : generator
225-
A generator that yields dictionaries keyed on the property
226-
name of the values to be used
227-
228-
"""
229-
return ({self._label: v} for v in self._itr)
230-
231-
def __len__(self):
232-
return len(self._itr)
233-
234-
@property
235-
def keys(self):
236-
"""
237-
The properties that this cycle loops over
238-
"""
239-
return set([self._label])
240-
241-
242-
class CompoundCycler(BaseCycler):
243-
"""
244-
A class to handle cycling multiple artist properties.
245-
246-
This class has two compositions methods '+' for 'inner'
247-
products of the cycles and '*' for outer products of the
248-
cycles.
249-
250-
This objects should not be created directly, but instead
251-
result of composition of existing `SingleCycler` and
252-
`CompoundCycler` objects.
253-
254-
Parameters
255-
----------
256-
left : BaseCycler
257-
The 'left' cycler
258-
259-
right : BaseCycler
260-
The 'right' cycler
261-
262-
op : function
263-
Function which composes the 'left' and 'right' cyclers.
264-
265-
"""
266-
def __init__(self, left, right, op):
267-
self._left = left
268-
self._right = right
269-
self._op = op
270-
l_key = left.keys
271-
r_key = right.keys
272-
if l_key & r_key:
273-
raise ValueError("Can not compose overlapping cycles")
274-
self._keys = l_key | r_key
275-
276-
def finite_iter(self):
277-
"""
278-
Return a finite iterator over the configurations in
279-
this cycle.
280-
281-
Returns
282-
-------
283-
gen : generator
284-
A generator that yields dictionaries keyed on the property
285-
name of the values to be used
286-
"""
287-
return self._compose()
288-
289-
def _compose(self):
290-
"""
291-
Private function to handle the logic of merging the dictionaries
292-
of the left and right cycles.
293-
294-
Yields
295-
------
296-
ret : dict
297-
A dictionary keyed on the property name of the values to be used
298-
"""
299-
for a, b in self._op(self._left.finite_iter(),
300-
self._right.finite_iter()):
301-
out = dict()
302-
out.update(a)
303-
out.update(b)
304-
yield out
305-
306-
def __len__(self):
307-
return len(list(self.finite_iter()))
308-
309-
@property
310-
def keys(self):
311-
"""
312-
The properties that this cycle loops over
313-
"""
314-
return self._keys

0 commit comments

Comments
 (0)
0