Allow getitem from a cycler
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by reading the cycler implementation and its existing tests, focusing on how cycles are iterated and how their length is exposed. Add indexing with the requested modulo behavior, and update tests to show that mycycler[i] returns the item at i % len(mycycler).
Written by the indexing model from the issue text.
Description
It would be useful to add __getitem__ functionality to cycler.
The use case is a "crowded" for loop where you want to get the cycler style without using a loop variable. Something like:
data_cycler = cycler('alpha', (0.2, 0.4, 0.6)) + cycler('color', ('r', 'g', 'b'))
fit_cycler = cycler('color', ('k', 'm', 'orange'))
for i, (data, fit) in enumerate(zip(data_list, fit_list)):
...
plt.plot('x', 'y', data=data, data_cycler[i])
plt.plot('x', 'y', data=data, fit_cycler[i])
...
In this case the index i is computed anyway, so using it for the cyclers would be handy, instead of adding the cycler inside zip().
Ideally mycycler[i] should return the item with index i % len(mycycler).
I haven't looked at the code yet. Would this be possible? Would a PR be welcome?
- Dominant language
- Python
- Stars
- 83
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matplotlib/cycler
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
matplotlib/cycler#94 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
matplotlib/cycler#41 · 10 comments · 5 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
matplotlib/cycler#30 · 1 comment ·
-
make a .mailmap file Open
Difficulty 1/5 Under an hour Newbie friendliness 35/100
matplotlib/cycler#17 ·
-
cycler interrogation Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
matplotlib/cycler#8 ·
All issues in matplotlib/cycler
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100