Skip to content

Closes 4777, creating a global seed - #4848

Merged
ajpotts merged 2 commits into
Bears-R-Us:mainfrom
drculhane:Closes-4777
Sep 10, 2025
Merged

ajpotts merged 2 commits into
Bears-R-Us:mainfrom
drculhane:Closes-4777

Conversation

@drculhane

@drculhane drculhane commented Sep 2, 2025 •

Copy link
Copy Markdown
Contributor

Addendum:

The mypy issue has been fixed, and the code simplified. Kudos to Amanda.


Update:

There's a bit of a challenge here.

(1) The file legacy.py, where I added the global seed code, already has functions rand, randint, standard_normal and uniform. All of these allow a seed parameter. The corresponding numpy functions don't have a seed parameter.
(2) The file generator.py, which creates the Generator class, also includes standard_normal and uniform functions, whose parameter lists don't 100% match the ones in legacy. The generator class lacks rand and randint.

I'd prefer to move all of these inside the Generator class, so that everything is aligned with numpy. But rand, randint, standard_normal and uniform have been working as they are now for some time, and even have unit tests that use the seed.

I am open to discussion.


Closes #4777

The code changes aren't substantial:

  • legacy.py has the code that creates the global seed, by creating a global generator (using the default_rng class). Any random number generator that's called as "ak.random.functionname" will use the global seed.
  • random_test.py tests that given the same seed, the results are identical through multiple iterations, and that given different seeds, they aren't.

Comment thread arkouda/numpy/random/legacy.py Resolved

@ajpotts ajpotts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for taking care of this one. Looks good!

Comment thread arkouda/numpy/random/legacy.py Resolved
@drculhane
drculhane force-pushed the Closes-4777 branch 2 times, most recently from b58c912 to 823e962 Compare September 8, 2025 12:24
Comment thread arkouda/numpy/random/legacy.py Resolved
Comment thread arkouda/numpy/random/legacy.py Resolved
Comment thread arkouda/numpy/random/legacy.py Resolved
Comment thread arkouda/numpy/random/legacy.py Resolved
Comment thread arkouda/numpy/random/legacy.py Resolved
Comment thread arkouda/numpy/random/legacy.py Resolved

@1RyanK 1RyanK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@ajpotts
ajpotts added this pull request to the merge queue Sep 10, 2025
Merged via the queue into Bears-R-Us:main with commit 274c24b Sep 10, 2025
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.

ak.rand to respect global seed.

4 participants