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

Fix subslice optimization for long, fully nan lines. #25978

Merged
merged 1 commit into from May 30, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented May 25, 2023

The subslice optimizer does not handle the case of fully nan inputs, so the relevant check in recache() is not whether x is sorted but really whether x is sorted and not fully nan. Fix that.

Previously, plt.plot([np.nan] * 2000, range(2000)) would crash.

Regression due to #24581, sorry about that.

PR summary

PR checklist

@anntzer anntzer added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: path handling labels May 25, 2023
@anntzer anntzer added this to the v3.7.2 milestone May 25, 2023
The subslice optimizer does not handle the case of fully nan inputs, so
the relevant check in recache() is not whether x is sorted but really
whether x is sorted and not fully nan.  Fix that.

Previously, `plt.plot([np.nan] * 2000, range(2000))` would crash.
@anntzer
Copy link
Contributor Author

anntzer commented May 28, 2023

Edit: also slightly tweaked the loop to fetch the stride info only once.

Copy link
Contributor

@oscargus oscargus left a comment

Choose a reason for hiding this comment

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

One may speculate which is the "best" order for the and statements (self._markevery is None seems quite simple and moving it will speed up some cases, probably also the string-comparisons), but it shouldn't be worse compared to the current state.

@oscargus oscargus merged commit d464cbf into matplotlib:main May 30, 2023
35 of 40 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 30, 2023
@anntzer anntzer deleted the if branch May 30, 2023 12:48
oscargus added a commit that referenced this pull request Jun 1, 2023
…978-on-v3.7.x

Backport PR #25978 on branch v3.7.x (Fix subslice optimization for long, fully nan lines.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: path handling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants