Skip to content
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

fix: ensure correct seed validation #3007

Merged
merged 1 commit into from
Oct 19, 2024
Merged

Conversation

rishav2404
Copy link
Contributor

Resolves #2952.

This pull request addresses the bug where setting seed=0 leads to non-deterministic behavior.

Description

Reimplemented commit (#3005).

What is the purpose of this pull request?

This pull request:

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

Please tell if there is any scope of correction.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

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
@kgryte kgryte added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 17, 2024
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @rishav2404.

@kgryte kgryte changed the title fix: ensure correct seed initialization with falsy values fix: ensure correct seed validation Oct 19, 2024
@kgryte kgryte merged commit 93560b9 into stdlib-js:develop Oct 19, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: setting seed=0 leads to non-deterministic behavior
2 participants