Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Adding 2d support to quadmesh set_array#16908
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -779,7 +779,8 @@ def update_scalarmappable(self): | ||
| """Update colors from the scalar mappable array, if it is not None.""" | ||
| if self._A is None: | ||
| return | ||
| # QuadMesh can map 2d arrays | ||
| if self._A.ndim > 1 and not isinstance(self, QuadMesh): | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Could we do the raveling here as ifisinstance(self,QuadMesh):self._A=self._A.ravel()else:raiseValueError(...) It keeps everything a bit more consistent shape wise? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That's actually what I had originally, but force-pushed over. The downside to it is if someone calls get_array() it is a different shape returned, which could cause confusion? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That is a fair point, but I am also worried about the shape stability of people who have code written against QuadMesh who are now going to be suprised that sometimes they get back 2d data. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That should only happen if they pass in 2d data, which was not possible before. So, I think all the before cases were 1d inputs and will return 1d inputs still. This is really for my selfish future motivation of wanting to call update animations without forgetting to ravel() and get the ValueError thrown my way. I completely agree though, it does add another layer of potential confusion and that should be weighed on pros/cons. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I am worried about the (hypothetical) that someone has written a function that takes in a I do see both sides of this and neither is obviously better. | ||
| raise ValueError('Collections can only map rank 1 arrays') | ||
| if not self._check_update("array"): | ||
| return | ||
| @@ -2044,8 +2045,10 @@ def draw(self, renderer): | ||
| else: | ||
| renderer.draw_quad_mesh( | ||
| gc, transform.frozen(), self._meshWidth, self._meshHeight, | ||
| coordinates, offsets, transOffset, | ||
| # Backends expect flattened rgba arrays (n*m, 4) for fc and ec | ||
| self.get_facecolor().reshape((-1, 4)), | ||
| self._antialiased, self.get_edgecolors().reshape((-1, 4))) | ||
| gc.restore() | ||
| renderer.close_group(self.__class__.__name__) | ||
| self.stale = False | ||