Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add consistency check for PathCollection sizes and edgecolors (#28833)#30138
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
base:main
Are you sure you want to change the base?
Conversation
…tlib#28833)This patch adds a check_consistency() method to PathCollection,which emits a warning if the number of sizes or edgecolors does notmatch the number of paths. The check is invoked during the draw()call to ensure it happens after all data is set.Also adds a unit test that triggers the warning for mismatched sizes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for the potential contribution. I think for now the main aim of the issue is to decide what we want to happen, so there is no guarantee this will get merged even if it works perfectly.
UserWarning: Number of sizes does not match number of paths. | ||
""" | ||
n_paths = len(self.get_paths()) | ||
if self._sizes is not None and len(self._sizes) not in (1, n_paths): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ifself._sizesisnotNoneandlen(self._sizes)notin (1,n_paths): | |
ifself._sizes.sizenotin (0,1,n_paths): |
Looking at theset_sizes
method, we always end up with an array here, though it may be size zero (if None was passed). I think this is the cause of at least some of the failing tests (any warnings are translated into errors in the tests).
This pull request addresses issue#28833 by adding a consistency check in
PathCollection
.The new
check_consistency()
method emits aUserWarning
if the number ofsizes
oredgecolors
does not match the number of
paths
. This method is called during thedraw()
call to catch anyinconsistencies before rendering.
A test (
test_pathcollection_size_mismatch_warning
) is included to validate the warning behavior.==================================================================