-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
[BUG]: setting seed=0 leads to non-deterministic behavior #2952
Labels
Comments
👋 Hi there! 👋 And thank you for opening your first issue! We will get back to you shortly. 🏃 💨 |
@mglezer You're right. It seems to be due to the following line:
@Planeshifter Looking back through the code history, is there a reason why you wrote this to have a weak check (e.g., |
1 task
rishav2404
added a commit
to rishav2404/stdlib
that referenced
this issue
Oct 14, 2024
The previous implementation used a direct property check (`config.seed`), which could inadvertently treat falsy values like `0` as missing, leading to incorrect random seed initialization. Changed the condition to explicitly check for the presence of the `seed` property using `Object.prototype.hasOwnProperty.call()`. This update ensures that seed initialization handles falsy but valid seed values correctly. Resolves stdlib-js#2952. This pull request addresses the bug where setting `seed=0` leads to non-deterministic behavior. No related issues. No questions for reviewers. No additional information relevant to this pull request. - [x] Read, understood, and followed the [contributing guidelines][contributing]. --- @stdlib-js/reviewers [contributing]: https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md
1 task
kgryte
changed the title
Setting seed=0 leads to non-deterministic behavior
[BUG]: setting seed=0 leads to non-deterministic behavior
Oct 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description
I expect that setting the seed to any positive integer, including zero, should lead to deterministic behavior. This is, for example, how Python's built-in random library works. However this is not the case for
@stdlib/random-shuffle
; the seed seems to be silently ignored. Either seeding with zero should produce deterministic behavior, or it should fail loudly, just like with negative seed values.Related Issues
Related issues # , # , and # .
Questions
No.
Demo
No response
Reproduction
or, throw an error and require strictly positive seeds.
The text was updated successfully, but these errors were encountered: