{{ message }}
Add consistency check for PathCollection sizes and edgecolors (#28833) - #30138
Open
BrunoWolf03 wants to merge 3 commits into
Open
BrunoWolf03 wants to merge 3 commits into
BrunoWolf03 wants to merge 3 commits into
Conversation
…tlib#28833) This patch adds a check_consistency() method to PathCollection, which emits a warning if the number of sizes or edgecolors does not match 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.
rcomer
reviewed
Jun 4, 2025
rcomer
left a comment
Member
There was a problem hiding this comment.
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.
Member
There was a problem hiding this comment.
Suggested change
| if self._sizes is not None and len(self._sizes) not in (1, n_paths): | |
| if self._sizes.size not in (0, 1, n_paths): |
Looking at the set_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).
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This pull request addresses issue #28833 by adding a consistency check in
PathCollection.The new
check_consistency()method emits aUserWarningif the number ofsizesoredgecolorsdoes 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.==================================================================