Fix clabel manual index#31706
Open
rahulrathnavel wants to merge 1 commit into
Open
Conversation
Member
|
@rahulrathnavel You have mixed commits for the clabel and violinplot issues. Please keep them in separate PRs. |
c4796aa to
ce62b25
Compare
Author
|
Hi @timhoffm, I've successfully force-pushed and completely separated the commits! This PR now strictly contains only the clabel fix. It looks like all the CI checks are passing perfectly now (as you suggested me-with the exception of the appveyor/pr Windows workflow, which seems to be the same upstream micromamba infrastructure error affecting other PRs right now). Please let me know if the code looks good to go or if you need any adjustments from my end! Thanks again for the guidance. |
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.
PR summary
closes #31702
This PR fixes a bug where using
ax.clabelwith themanualkeyword raises anIndexErrorif the user specifies a subset of contour levels (fewer than the total available in the contour set).What problem does it solve and reasoning:
In
lib/matplotlib/contour.py, theadd_label_nearfunction was incorrectly usingidx_level_minto accessself.labelLevelListandself.labelCValueList. Becauseidx_level_mincorresponds to the index of the entire contour set, passing a filtered subset of levels caused it to search out-of-bounds.As suggested by the original issue author, I swapped
idx_level_minfor thelevelvariable, which correctly maps to the current subset being labeled. I also added a minimal pytest intest_contour.pythat verifies a manual label can be placed on a subset contour without throwing an exception.AI Disclosure
I used an AI assistant strictly to help navigate the repository structure, locate the specific lines in
contour.py, and draft the boilerplate for the minimalpytestfunction. The core logic fix was suggested by the issue author, and I manually applied, reviewed, and tested the changes locally to ensure complete Matplotlib compliance.PR checklist