Skip to content

Do not check value of parameters from rcParam (and check rcParam befo… #26167

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Jun 22, 2023

…re using them)

Inspired by some changes in #26164, but separated as they are not directly connected to that (some that could have been here might have gone in there though...).

If we get the rcParam (and that is checked) or set an argument to a valid value, it is not required to check with check_in_list.

Some rcParams were not checked when loaded, only when used.

Finally, small methods where the likely thing is that the correct parameter is passed and there are if-claused anyway, are checked at the end rather than the beginning.

PR summary

PR checklist

Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

Just one question.

Comment on lines 741 to +744
if style is None:
style = mpl.rcParams['font.style']
_api.check_in_list(['normal', 'italic', 'oblique'], style=style)
else:
_api.check_in_list(['normal', 'italic', 'oblique'], style=style)
Copy link
Member

@timhoffm timhoffm Jun 22, 2023

Choose a reason for hiding this comment

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

I'm not a fan of this kind of change. The code get's longer, harder to follow and more prone to errors.

Double checking the rcParam value here does not hurt. The only disadvantage are 300ns performance loss (which I claim to be negigible in any real-world application). But since the rcParam validation is an independent concept, we don't have a guarantee that they are synchronous. Such differences could be an oversight. But I can also imagine cases where rcParams are used in multiple places and have a slightly broader acceptance range than what a specific function supports.

Copy link
Member Author

Choose a reason for hiding this comment

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

The thing is that those 300 ns are multiplied with a huge number in many situations.

Copy link
Member

Choose a reason for hiding this comment

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

What is huge? If huge * 300ns > 2% of the total plot time, we may start to consider, otherwise, the benefit is negligible.

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.

3 participants