BUG: Made `setp` accept arbitrary iterables #6217

Merged
merged 1 commit into from Mar 26, 2016

Conversation

Projects
None yet
4 participants
Contributor

madphysicist commented Mar 24, 2016

Previously only accepted sequences.

Fixes #6212

mdboom added the needs_review label Mar 24, 2016

Contributor

madphysicist commented Mar 24, 2016

I don't think the broken Travis test is something I did...

Contributor

madphysicist commented Mar 24, 2016

Also, while looking through some old code, I found the original use-case where this came up. It's actually not too contrived: pyplot.setp(axes.spines.values(), color='gray'). Fine in Py2, breaks in Py3.

Owner

tacaswell commented Mar 24, 2016

There are a transient failures that we have not tracked down yet, restarted the test.

@madphysicist madphysicist commented on the diff Mar 24, 2016

lib/matplotlib/artist.py
@@ -1526,12 +1529,12 @@ def setp(obj, *args, **kwargs):
>>> setp(line)
... long output listing omitted
- :func:`setp` operates on a single instance or a list of instances.
@madphysicist

madphysicist Mar 24, 2016

Contributor

While minor, I think you should absorb the doc changes into your PR.

Owner

tacaswell commented Mar 24, 2016

I think both of the fixes need to go in. One issue with listifying generators in functions is the side effect, ex

def worker(inp):
    inner = list(inp)
    print("should count to {}".format(len(inner)))


gen_example = (j for j in range(15))

worker(gen_example)
for i in gen_example:
    print(i)

will not behave correctly (you can make this sort of thing work via tee).

@madphysicist @madphysicist madphysicist BUG: Made `setp` accept arbitrary iterables
Previously only accepted sequences.
Fixes #6212

Shamelessly borrows from `FIX: handle arbitrary iterables in setp #6220`
8881680

@tacaswell tacaswell merged commit d208471 into matplotlib:master Mar 26, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

tacaswell removed the needs_review label Mar 26, 2016

Owner

tacaswell commented Mar 26, 2016

I am leaning no on backporting unless someone disagrees.

Contributor

madphysicist commented Mar 26, 2016

That makes perfect sense in this case. As the title indicates, this is not strictly even a bug. If it hasn't been fixed by now, it's been worked around or gone unnoticed. The work-around is simple enough that it doesn't need a backport.

madphysicist deleted the madphysicist:madphysicist-patch-1 branch Mar 26, 2016

QuLogic added this to the 2.1 (next point release) milestone Jul 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment