Skip to content
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

Improve legend(loc='best') warning and test #26483

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Aug 10, 2023

PR summary

The consider argument from Legend._find_best_position can be removed, as no-one ever uses it and this is a private method.

Because of an early return, the warning that loc='best' is slow can sometimes not be triggered, so ensure that is the case.

Finally, improve the test for this warning. By patching the timer instead of using actually large data, we can both:

  1. speed up these tests (~7.5s vs <0.2s for both), and
  2. consistently trigger the warning even on systems which are fast (such as the M1 systems on Cirrus Start using Cirrus CI #24597.)

Also, copy the test data from test_legend_auto3, which correctly hits all candidate locations for the 'best' legend locator without having to fill up the entire Axes with data.

PR checklist

It is never passed in explicitly, and this is otherwise private.
If a candidate location was picked, then that would be returned directly
without warning even if it took just as long.
@QuLogic QuLogic changed the title Improve legend(loc='best warning Improve legend(loc='best') warning and test Aug 10, 2023
@QuLogic QuLogic marked this pull request as ready for review August 10, 2023 04:39
By patching the timer instead of using actually large data, we can both
a) speed up these tests (~7.5s vs <0.2s for both), and b) consistently
trigger the warning even on systems which are fast (such as the M1
systems on Cirrus.)

Also, copy the test data from `test_legend_auto3`, which correctly hits
all candidate locations for the 'best' legend locator without having to
fill up the entire Axes with data.
@tacaswell tacaswell added this to the v3.9.0 milestone Aug 10, 2023
@ksunden ksunden merged commit fa3aea9 into matplotlib:main Aug 10, 2023
39 checks passed
@QuLogic QuLogic deleted the loc-best-warning branch August 10, 2023 19:20
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.

None yet

3 participants