Add consistency check for PathCollection sizes and edgecolors (#28833)#30138
Add consistency check for PathCollection sizes and edgecolors (#28833)#30138BrunoWolf03 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
left a comment
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.
| 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.
| 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).
|
This needs a decision on the original issue #28833 first:
If we decide, we want this, the implementation should be generalized to |
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.==================================================================