X Tutup
Skip to content

MNT: Normalize internal set_foreground calls to RGBA#31119

Merged
QuLogic merged 8 commits intomatplotlib:mainfrom
sanrishi:fix/issue-31105-clean
Feb 18, 2026
Merged

MNT: Normalize internal set_foreground calls to RGBA#31119
QuLogic merged 8 commits intomatplotlib:mainfrom
sanrishi:fix/issue-31105-clean

Conversation

@sanrishi
Copy link

@sanrishi sanrishi commented Feb 8, 2026

PR summary

This PR refactors internal calls to set_foreground within lib/matplotlib/ to ensure they pass normalized RGBA tuples with the isRGBA=True flag. This change aligns with the internal cleanup requested in issue #31105, reducing the overhead for backends to handle color normalization.

  • No changes to public API or behavior; strictly an internal refactor.

PR checklist

@sanrishi sanrishi requested a review from timhoffm February 9, 2026 14:30
@rcomer
Copy link
Member

rcomer commented Feb 9, 2026

Have you considered these two?

gc0.set_foreground(ec)

gc.set_foreground(self.get_markeredgecolor())

@sanrishi
Copy link
Author

sanrishi commented Feb 10, 2026

Thanks for the review @rcomer
Changes is committed as suggested after passing locally
Review!

@sanrishi
Copy link
Author

@timhoffm There has been couple of days since it open and ready for review could you?

if Nlinestyles:
gc0.set_dashes(*ls)
if len(ec) == 4 and ec[3] == 0.0:
ec_is_seq = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is looping through the properties of a Collection. Have you learned anything about Collection edgecolors that can help you simplify this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Collection edgecolors are already RGBA via to_rgba_array, so I simplified the code to assume RGBA in the common case and kept a fallback for other inputs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances does the fallback get used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback is only for non‑Collection callers that pass non‑RGBA values (e.g., color strings) into draw_path_collection/_iter_collection.

Collection always normalizes via mcolors.to_rgba_array, so the main path is RGBA. For other inputs we can’t safely assume RGBA, so we fall back to set_foreground(ec).

@sanrishi sanrishi requested a review from rcomer February 16, 2026 15:36
else:
gc0.set_foreground(ec_rgba, isRGBA=True)
else:
gc0.set_foreground(ec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This see seems a bit off. You do a whole song and dance to convert many cases to rgba, but then bail out. What is the motivation for this solution? Wouldn’t it be simpler to call to_rgba and be done?

Copy link
Author

@sanrishi sanrishi Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification chief!

@sanrishi sanrishi requested a review from timhoffm February 17, 2026 16:33
@rcomer
Copy link
Member

rcomer commented Feb 17, 2026

Anyone can merge when CI is green (or as green as may be expected with the flaky tests).

Recommend squash-merge.

@rcomer rcomer added this to the v3.11.0 milestone Feb 17, 2026
@rcomer
Copy link
Member

rcomer commented Feb 17, 2026

I took the liberty of unlinking the issue as I think there is more to do in terms of discouraging/deprecating public use of isRGBA=False.

@sanrishi
Copy link
Author

Question : When is matplotlib 3.11.0 is scheduled ?

@timhoffm
Copy link
Member

Soonish, but we need to get the font and text overhaul in first. #30161

@sanrishi
Copy link
Author

sanrishi commented Feb 17, 2026

By the way chief @timhoffm
Google is releasing the project ideasfor gsoc, are matplotlib taking part in it?

@story645
Copy link
Member

story645 commented Feb 17, 2026

Google is releasing the project ideasfor gsoc, are matplotlib taking part in it?

If we get accepted, it'll be under numfocus

@sanrishi
Copy link
Author

It means matplotlib come back this year for gsoc 2026 and have project ideas?
Are we have potential for mentorship this year?

@QuLogic QuLogic merged commit 71f86ab into matplotlib:main Feb 18, 2026
38 of 40 checks passed
@story645
Copy link
Member

it means matplotlib come back this year for gsoc 2026 and have project ideas?
Are we have potential for mentorship this year?

If Numfocus gets accepted, then yes. You'll then find our project list linked through NumFocus.

@sanrishi sanrishi deleted the fix/issue-31105-clean branch February 18, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup