Skip to content

Commit

Permalink
fixes seeds
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
  • Loading branch information
wyli committed Feb 4, 2021
1 parent b98f016 commit 7670055
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tests/test_rand_lambdad.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class RandTest(Randomizable):
"""

def randomize(self, data=None):
self.set_random_state(seed=134)
self._a = self.R.random()
self.set_random_state(seed=None)

def __call__(self, data):
self.randomize()
Expand All @@ -39,11 +37,12 @@ def test_rand_lambdad_identity(self):
data = {"img": img, "prop": 1.0}

test_func = RandTest()

test_func.set_random_state(seed=134)
expected = {"img": test_func(data["img"]), "prop": 1.0}
test_func.set_random_state(seed=134)
ret = RandLambdad(keys=["img", "prop"], func=test_func, overwrite=[True, False])(data)
self.assertTrue(np.allclose(expected["img"], ret["img"]))
self.assertTrue(np.allclose(expected["prop"], ret["prop"]))
np.testing.assert_allclose(expected["img"], ret["img"])
np.testing.assert_allclose(expected["prop"], ret["prop"])


if __name__ == "__main__":
Expand Down

0 comments on commit 7670055

Please sign in to comment.