Skip to content

Commit

Permalink
Ensure unary_func seeding is deterministic across processes (#825)
Browse files Browse the repository at this point in the history
Co-authored-by: Manolis Papadakis <[email protected]>
  • Loading branch information
manopapad and manopapad authored Mar 2, 2023
1 parent c85c970 commit 45cb800
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 45cb800

Please sign in to comment.