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

BUG: check for closed path in Polygon.set_xy() #1018

Closed
wants to merge 2 commits into from

Conversation

jakevdp
Copy link
Contributor

@jakevdp jakevdp commented Jul 17, 2012

This was something unexpected I came across: I had to dig through the code to see why it didn't behave as I thought it should. I'm not sure whether it should be changed (I can see arguments both ways) but I thought I'd bring it up just in case.

Former behavior:

>>> xy = [[0,0], [0,1], [1,1]]
>>> p = Polygon(xy, closed=True)
>>> p.get_xy()
array([[ 0.,  0.],
       [ 0.,  1.],
       [ 1.,  1.],
       [ 0.,  0.]])
>>> p.set_xy(xy)
>>> p.get_xy()
array([[ 0.,  0.],
       [ 0.,  1.],
       [ 1.,  1.]])

This PR changes things so the second output is the same as the first, for both closed = True and closed = False.

@pelson
Copy link
Member

pelson commented Jul 17, 2012

I'm happy that this is like-for-like behaviour with the added set_xy fix. Because there is a behavioural change (or bug fix), probably needs an entry in the doc/api/api_changes.rst doc.

Other than that, gets my +1.

@efiring
Copy link
Member

efiring commented Jul 17, 2012

I think the idea is valid, but additional refactoring is needed. The logic in set_closed starting with "if closed:" should be moved into set_xy(), so that the closing point is not duplicated unnecessarily. set_closed would then end with "self.set_xy(self.get_xy)"

@mdboom
Copy link
Member

mdboom commented Aug 3, 2012

A agree with @efiring, but other than that, looks ok. Let's add a unit test, too.

efiring added a commit to efiring/matplotlib that referenced this pull request Aug 12, 2012
This is a modification of that pull request, with a test added.
@efiring
Copy link
Member

efiring commented Aug 12, 2012

This is superceded by #1071, so I am closing it.

@efiring efiring closed this Aug 12, 2012
efiring added a commit that referenced this pull request Aug 12, 2012
patches.polygon: fix bug in handling of path closing, #1018.
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