Skip to content

Commit

Permalink
Use a fixed seed for finite differences tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Jul 3, 2024
1 parent ef1383c commit 8dd7adf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/metatensor-operations/tests/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def function(array):
tensor_2 = _gradcheck.cartesian_cubic(array)
return metatensor.add(tensor_1, tensor_2)

array = np.random.rand(5, 3)
rng = np.random.default_rng(seed=123456)
array = rng.random((5, 3))
_gradcheck.check_finite_differences(function, array, parameter="g")


Expand All @@ -287,5 +288,7 @@ def function(array):
tensor_2 = _gradcheck.cartesian_cubic(array)
return metatensor.add(tensor_1, tensor_2)

array = torch.rand(5, 3, dtype=torch.float64)
rng = torch.Generator()
rng.manual_seed(123456)
array = torch.rand(5, 3, dtype=torch.float64, generator=rng)
_gradcheck.check_finite_differences(function, array, parameter="g")

0 comments on commit 8dd7adf

Please sign in to comment.