Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF - prevent a TypeError for lists of vertices in set_marker #1840

Closed
wants to merge 1 commit into from

Conversation

ajdawson
Copy link
Contributor

The documentation for setting markers (http://matplotlib.org/api/artist_api.html#matplotlib.lines.Line2D.set_marker) suggests that:

a list of (x, y) pairs used for Path vertices

is an acceptable input. However, if one tries to use a Python list a TypeError is returned. This is because the set_marker code attempts to use the marker specification as the key in a dictionary, which fails because lists are not hashable. To avoid this I added an extra condition to the logic that makes sure the input is not a list before attempting to use it as a dictionary key (taking advantage of lazily evaluated boolean conditions). This allows the final conditional to be executed which happily constructs a path from a list of vertices, just as it does from a tuple of vertices.

@pelson
Copy link
Member

pelson commented Mar 21, 2013

Thanks @ajdawson - would you be able to add a test? (updating an existing test, if appropriate, would be fine)

@ajdawson
Copy link
Contributor Author

I added a new test in test_axes.py, it seemed the most appropriate option.

@ajdawson
Copy link
Contributor Author

OK I've used extensions=['png'] and removed the pdf and svg test images. I overwrote the test image with one that contains no text without thinking about it. The test function is written so that it would produce text, but has remove_text=True in the image comparison decorator, so I guess this is OK?

@dmcdougall
Copy link
Member

In my opinion, this is fixing a bug and should target v1.2.x. What do others think?

@efiring
Copy link
Member

efiring commented Mar 23, 2013

Yes, it is fixing a bug.

@ajdawson
Copy link
Contributor Author

I made a new PR #1854 that introduces this change into the v1.2.x branch.

@ajdawson ajdawson closed this Mar 24, 2013
@ajdawson ajdawson deleted the fix-marker-list branch July 18, 2013 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants