-
-
Notifications
You must be signed in to change notification settings - Fork 26k
Python wrapper and tests for sklearn/svm/newrand/ #17157
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
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9069c3f
Implemented issue #16862
Justin-Huber 7a92336
Implemented issue #16862
Justin-Huber 901a1b9
Ready for pull request
Justin-Huber 9daf268
Cleaned up redundancies
Justin-Huber 4734ad1
Removed test_set_seed_wrap for now
Justin-Huber edfaf72
Update sklearn/svm/tests/test_bounds.py
Justin-Huber d8f720d
Review feedback changes
Justin-Huber 6640f90
Review feedback changes (merge conflicts resolved)
Justin-Huber b95d87f
Style fixes
Justin-Huber e0e8e6d
np.quantile -> np.percentile
Justin-Huber 83fb693
Update sklearn/svm/src/newrand/newrand.h
Justin-Huber b4c71f4
Update sklearn/svm/tests/test_bounds.py
Justin-Huber 90a85f3
linting fix
Justin-Huber 9d1bc44
linting fix
Justin-Huber 5215fee
linting fix
Justin-Huber f266f15
Added deterministic test for mt19937 in svm/newrand.h
Justin-Huber b37f3b4
Linting fix
Justin-Huber 1d68995
Review changes
Justin-Huber 586aef6
Update sklearn/svm/tests/test_bounds.py
Justin-Huber b3395ba
Update sklearn/svm/tests/test_bounds.py
Justin-Huber 8abd97c
Update sklearn/svm/tests/test_bounds.py
Justin-Huber 8d88b42
Update test_bounds.py
Justin-Huber f62ed4a
Linting fixes
Justin-Huber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Wrapper for newrand.h | ||
|
||
""" | ||
|
||
cdef extern from "newrand.h": | ||
void set_seed(unsigned int) | ||
unsigned int bounded_rand_int(unsigned int) | ||
|
||
def set_seed_wrap(unsigned int custom_seed): | ||
set_seed(custom_seed) | ||
|
||
def bounded_rand_int_wrap(unsigned int range_): | ||
return bounded_rand_int(range_) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Don't you think that it would be safer to keep this ? Indeed
bounded_rand_int
is marked asinline
so I guess (but I'm no C++ expert) that the input can actually be anything, there is absolutely no protection. At least having this cast would ensure that when this code is badly used directly from C++ there are no side effects (from python that's already safe thanks to the Cython wrapper). What do you think ?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.
Now that the input to bounded_rand_int is uint32_t, I think this extra step is redundant (casting uint32_t to uint32_t)
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.
ok !