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

Ensure unary_func seeding is deterministic across processes #825

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/integration/test_unary_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#

import argparse
from zlib import adler32

import numpy as np
import pytest
Expand All @@ -27,8 +28,7 @@ def deterministic_op_test(func):
# This enforces that inputs are always the same whether
# running all tests or a single test with -k.
def wrapper_set_seed(op, *args, **kwargs):
# np seeds must be limited to 32-bits
np.random.seed(hash(op) & 0xFFFFFFFF)
np.random.seed(adler32(bytes(op, "utf-8")))
func(op, *args, **kwargs)
func(op, *args, **kwargs)

Expand Down