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

More flexible input for PolygonVisual #1481

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

campagnola
Copy link
Member

  • PolygonVisual can optionally receive PolygonData as its input rather than just an array of positions. This allows more complex edge specification.
  • PolygonData makes use of its edges property (previously it was ignored).

… optionally use PolygonData instead of position array
@campagnola
Copy link
Member Author

Open question: should the PolygonData.faces property be read-only? I can't think of a situation where we want the user to be able to set it; the whole purpose of PolygonData seems to be triangulation.

@campagnola
Copy link
Member Author

..and while I'm digging, the convex_hull property seems to have no (implemented) purpose.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed convex hull doesn't seem to do anything. Do we maybe want to keep it but raise a NotImplementedError in the property?

edges = np.empty((npts-1, 2), dtype=np.uint32)
edges[:, 0] = np.arange(npts)
edges[:, 1] = edges[:, 0] + 1
self._edges = edges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to move this chunk of code to the setter and then in init use self.edges = edges (instead of the private)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer to avoid any potentially expensive operations until I am sure they are needed. For example, the user could create the PolygonData with just vertices, and then set the edges manually later on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but self._edges is never read directly, it is always self.edges. Additionally self._edges is never written to directly except for init. This block of code is just a validation step of the edges being applied to the PolygonData object so shouldn't that validation happen at set (one time) rather than at read (possibly many times).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the latest version; the code makes a bit more sense now. self.edges can be either specified manually (at init or by setter) or automatically generated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it makes more sense now because I realize that they are just autogenerated from the vertices. However, when you set vertices don't you need to set self._edges to None so they are regenerated?

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something in the back of my head says this should be possible without _auto_edges but I can't think of how so LGTM.

@djhoese
Copy link
Member

djhoese commented May 16, 2018

...except for the failed tests that is.

@djhoese
Copy link
Member

djhoese commented Aug 6, 2018

@campagnola Any chance you can fix the CI failures?

@djhoese
Copy link
Member

djhoese commented May 3, 2020

@campagnola You around? Think you could merge master in to this and see what the state of the tests are?

@djhoese djhoese self-assigned this May 3, 2020
@djhoese djhoese closed this Apr 28, 2021
@djhoese djhoese deleted the branch vispy:main April 28, 2021 19:00
@djhoese djhoese reopened this Apr 28, 2021
@djhoese djhoese closed this Apr 28, 2021
@djhoese djhoese deleted the branch vispy:main April 28, 2021 19:27
@djhoese djhoese reopened this Apr 28, 2021
@djhoese djhoese changed the base branch from master to main April 28, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants