Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplify implementation of _is_sorted. #24581

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

Merged
merged 1 commit into from
Dec 2, 2022
Merged

Simplify implementation of _is_sorted. #24581

merged 1 commit into from
Dec 2, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 2, 2022

We don't need a separate specialization for ints (we can rely on the compiler to inline isnan as always false), and having a separate loop to find the first non-nan value isn't necessary either.

One change in behavior this causes (in this private function) is that a fully nan input is considered as being sorted, but this is consistent with empty inputs being considered sorted too, and also OK with the actual use of the function (determine whether to go through a fast path in drawing lines -- fully nan lines are not drawn anyways).

followup to #24575, which I unfortunately have to slightly revert (going back to x != x) due to the lack of isnan(IntegralValue) on MSVC (https://stackoverflow.com/questions/61646166/how-to-resolve-fpclassify-ambiguous-call-to-overloaded-function), even though cppreference declares that it should exist (https://en.cppreference.com/w/cpp/numeric/math/isnan)...

PR Summary

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

We don't need a separate specialization for ints (we can rely on the
compiler to inline isnan<int> as always false), and having a separate
loop to find the first non-nan value isn't necessary either.

One change in behavior this causes (in this private function) is that a
fully nan input is considered as being sorted, but this is consistent
with empty inputs being considered sorted too, and also OK with the
actual use of the function (determine whether to go through a fast path
in drawing lines -- fully nan lines are not drawn anyways).
@ksunden ksunden added this to the v3.7.0 milestone Dec 2, 2022
@ksunden ksunden merged commit 5bd9fdf into matplotlib:main Dec 2, 2022
@anntzer anntzer deleted the is branch December 2, 2022 21:40
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