-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…om_shuffle with shuffle and used mersenne twister engine to generate uniform random bit generator for the shuffle.
It looks like This seems reasonable and at least our tests are not sensitive to the different random order. |
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. The |
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. |
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? |
@tybeller if you edit your original post here and put “closes #24010“, that will link the issue to the PR, see https://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 |
Added API notes for changed output from TrapezoidMapTriFinder, triangulation interpolation, and refinement
There was a problem hiding this 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 change Co-authored-by: Ian Thomas <ianthomas23@gmail.com>
@@ -0,0 +1,3 @@ | |||
Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
would solve the failing doc build (if I got the length right...).
There was a problem hiding this comment.
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. | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
clarified that the conditions of the change in output
@tybeller The definition of |
Here is a possible improved api change note:
|
Updated with ianthomas23's API documentations
@tybeller Don't forget the changes in |
src/tri/_tri.cpp
Outdated
_seed = (_seed*_a + _c) % _m; | ||
return (_seed*max_value) / _m; | ||
} | ||
} |
There was a problem hiding this comment.
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
Thank you for this work @tybeller and congratulations on your first merged Matplotlib PR 🎉 Hopefully we will hear from you again! |
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
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).