Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix incorrect stride calculations in LogLocator.tick_values()#25405

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 7 commits intomatplotlib:mainfromhaval0:issue/24092
Mar 28, 2023

Conversation

II-Day-II
Copy link
Contributor

PR Summary

Resolves#24092

A simplification of the stride calculation inthis commit seems to have introduced some incorrect behavior, as the simplified version isn't mathematically equivalent to the old one. This caused the method to return an empty array when it shouldn't, which meant ticks would not appear on the grid axes.

This PR reverts the stride calculation in the case wherempl.rcParams['_internal.classic_mode'] isFalse to one equivalent to the while-loop the simplification replaced, as well as adding tests for the scenario described in#24092.

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (andpytest passes)
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • [N/A] New plotting related features are documented with examples.

Release Notes

  • [N/A] New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • [N/A] API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • [N/A] Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

haval0and others added4 commitsMarch 1, 2023 16:44
The test cases are based on the demonstration of the issue in upstreamissuematplotlib#24092The test case for bad plot (test_tick_values_not_empty) should failuntil we implement our fix.The test case for good plot (test_tick_values_correct) should alreadysuceed and continue to succeed after we implement our fix.
"classic_mode" had to be disabled for the test to successfully replicatethe normal behavior of matplotlib. Now the test produces an empty list,which is what should be fixed.
feat: add 2 tests based on good/bad plot from upstream issue
The attempt to simplify the stride calculation in `a06f343dee3cebf035b74f65ea00b8842af448e9` seems to be the cause of the problem. Using an approach equivalent to what was there before hopefullyresolvesmatplotlib#24092.
Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping@matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@oscargus
Copy link
Member

Seems to be some minor numerical errors. Maybe useassert_array_almost_equal instead?

uses the assert_almost_equal function instead of assert_array_equal
@rcomer
Copy link
Member

assert_allclose is now recommended in the numpy docs - see note here:
https://numpy.org/doc/stable/reference/generated/numpy.testing.assert_array_almost_equal.html#numpy-testing-assert-array-almost-equal

oscargus reacted with thumbs up emoji

@II-Day-II
Copy link
ContributorAuthor

Other tests in the file useassert_almost_equal, so we try that instead.

@QuLogicQuLogic requested a review fromanntzerMarch 7, 2023 23:15
@anntzer
Copy link
Contributor

Seems reasonable, but going through the algebra again I think the correct stride value is simplynumdec // numticks + 1 (without the +1 on the numerator)? This seems to fix the issue and to pass the tests too.

@II-Day-II
Copy link
ContributorAuthor

Ok! That's more efficient for sure, we'll change it and make another commit.

Copy link
Contributor

@anntzeranntzer left a comment

Choose a reason for hiding this comment

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

post-ci.

@QuLogic
Copy link
Member

post-ci.

@anntzer was that supposed to be an approval?

@anntzer
Copy link
Contributor

Woops, indeed.

@jklymakjklymak merged commit9e52bc8 intomatplotlib:mainMar 28, 2023
@jklymak
Copy link
Member

Congratulations on your first successful PR!

II-Day-II and haval0 reacted with hooray emoji

@QuLogicQuLogic added this to thev3.8.0 milestoneMar 28, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@anntzeranntzeranntzer approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

[Bug]: LogLocator with subs argument fragile.
8 participants
@II-Day-II@oscargus@rcomer@anntzer@QuLogic@jklymak@melissawm@haval0

[8]ページ先頭

©2009-2025 Movatter.jp