Skip to content

Commit

Permalink
Make unit tests use a common seed function
Browse files Browse the repository at this point in the history
  • Loading branch information
kratman committed Oct 3, 2023
1 parent 1b4d444 commit 853f920
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#
import unittest
import hashlib
import numpy as np
from functools import wraps
from types import FunctionType

import pybamm


def FixRandomSeed(method):
"""
Expand All @@ -23,7 +24,7 @@ def FixRandomSeed(method):

@wraps(method)
def wrapped(*args, **kwargs):
np.random.seed(
pybamm.util.set_random_seed(
int(hashlib.sha256(method.__name__.encode()).hexdigest(), 16) % (2**32)
)
return method(*args, **kwargs)
Expand Down

0 comments on commit 853f920

Please sign in to comment.