Skip to content

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 #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
@rishav2404 rishav2404 deleted the bugg-2952 branch October 21, 2024 18:10
aayush0325 pushed a commit to aayush0325/stdlib that referenced this pull request Nov 11, 2024
The previous implementation used a direct property check (`config.seed`),
which could inadvertently treat falsy values, such as `0`, as missing, leading
to incorrect seed validation.

PR-URL: stdlib-js#3007
Closes: stdlib-js#2952
Reviewed-by: Athan Reines <[email protected]>
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