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

Replaced std::random_shuffle with std::shuffle in tri#24062

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
tacaswell merged 14 commits intomatplotlib:mainfromtybeller:shuffleFix
Oct 28, 2022

Conversation

tybeller
Copy link
Contributor

@tybellertybeller commentedOct 1, 2022
edited
Loading

PR Summary

Replaced std::random_shuffle with std::shuffle for compliance with C++17. Deleted RandomNumberGenerator class. Included random library and used 32 bit mersenne twister as uniform random bit generator for shuffle. Note: TrapezoidMapTriFinder, triangulation interpolation, and refinement may yield different results due to this change.Closes#24010

PR Checklist

Tests and Styling

  • [N/A ] Has pytest style unit tests (andpytest passes).
  • [N/A ] IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

…om_shuffle with shuffle and used mersenne twister engine to generate uniform random bit generator for the shuffle.
@tacaswelltacaswell added this to thev3.7.0 milestoneOct 1, 2022
@tacaswell
Copy link
Member

It looks likestd::shuffle came in in c++11 which we just switch to having as our floor. It looks like moving that forwards was a good choice as it made this simple (I assume with enough#ifdef we could support a wider range of c++ versions....).

This seems reasonable and at least our tests are not sensitive to the different random order.

@ianthomas23
Copy link
Member

Thanks@tybeller. It is usual to mention the issue that the PR closes within the text (not just within the title) so that there is a link between the two and the issue automatically closes when the PR is merged.

Also, I said in the issue that it would need a release note but I realise now that this is classified as a behaviour change ("API that stays valid but will yield a different result") which therefore needs an API change note. TheREADME file in thenext_api_changes directory describes what is required here, seehttps://github.com/matplotlib/matplotlib/blob/main/doc/api/next_api_changes/README.rst and let me know if this is not clear enough and I will help out.

@tybeller
Copy link
ContributorAuthor

Thank you, sorry for any issues as this is my first time. If I'm reading this right I need to add the issue within the pull request and add and API change note correct? I'll get working on that and please let me know if there is anything else I'm missing.

@tybeller
Copy link
ContributorAuthor

One question, is there a way to edit these changes into this pull request or should I make a separate pull request with these fixes?

@rcomer
Copy link
Member

rcomer commentedOct 1, 2022
edited
Loading

@tybeller if you edit your original post here and put “closes#24010“, that will link the issue to the PR, seehttps://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

Once you make any changes to you branch and push them to github, they will show in this pull request. There is advice for updating your branch in response to the review here:https://matplotlib.org/devdocs/devel/coding_guide.html#summary-for-pull-request-authors

@tybellertybeller changed the title c++17 removed random_shuffle #24010Replaced std::random_shuffle with std::shuffle in triOct 2, 2022
Added API notes for changed output from TrapezoidMapTriFinder, triangulation interpolation, and refinement
Copy link
Member

@ianthomas23ianthomas23 left a comment

Choose a reason for hiding this comment

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

The code changes are fine, just a slight tweak to the API change note and this will be good to merge.

Fix api changeCo-authored-by: Ian Thomas <ianthomas23@gmail.com>
@@ -0,0 +1,3 @@
Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

would solve the failing doc build (if I got the length right...).

Copy link
Member

Choose a reason for hiding this comment

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

If you're having trouble aligning the underline, then that's a sign the title is probably too long. I would leave out all of the details and just say "Change in triangulation output ..." Also, no trailing period in titles.

@@ -0,0 +1,3 @@
Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

If you're having trouble aligning the underline, then that's a sign the title is probably too long. I would leave out all of the details and just say "Change in triangulation output ..." Also, no trailing period in titles.

@@ -0,0 +1,3 @@
Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may give different results.
Copy link
Member

Choose a reason for hiding this comment

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

Different results how? Does a plot change? Is the order different? This is too vague and as a user I have no idea whether I need to do anything here. Also, please word-wrap lines at 80 characters.

tybellerand others added3 commitsOctober 5, 2022 03:34
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
clarified that the conditions of the change in output
@ianthomas23
Copy link
Member

@tybeller The definition ofclass RandomNumberGenerator at the end ofsrc/tri/_tri.h can be removed.

@ianthomas23
Copy link
Member

Here is a possible improved api change note:

``TrapezoidMapTriFinder`` uses different random number generator~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The random number generator used to determine the order of insertion oftriangle edges in ``TrapezoidMapTriFinder`` has changed. This can result in adifferent triangle index being returned for a point that lies exactly on anedge between two triangles. This can also affect triangulation interpolationand refinement algorithms that use ``TrapezoidMapTriFinder``.

@ianthomas23
Copy link
Member

@tybeller Don't forget the changes insrc/tri/_tri.h.

_seed = (_seed*_a + _c) % _m;
return (_seed*max_value) / _m;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Please end the file with an empty line. That will fix the pre-commit issue. (The pyside6 issue is fixed in#24158.)

added empty line at end
@tacaswelltacaswell merged commit1bb5816 intomatplotlib:mainOct 28, 2022
@tacaswell
Copy link
Member

Thank you for this work@tybeller and congratulations on your first merged Matplotlib PR 🎉 Hopefully we will hear from you again!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@oscargusoscargusoscargus left review comments

@ianthomas23ianthomas23ianthomas23 approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

c++17 removed random_shuffle
6 participants
@tybeller@tacaswell@ianthomas23@rcomer@QuLogic@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp