Skip to content

Commit 8dd7adf

Browse files
committed
Use a fixed seed for finite differences tests
1 parent ef1383c commit 8dd7adf

File tree

1 file changed

+5
-2
lines changed
  • python/metatensor-operations/tests

1 file changed

+5
-2
lines changed

python/metatensor-operations/tests/add.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ def function(array):
276276
tensor_2 = _gradcheck.cartesian_cubic(array)
277277
return metatensor.add(tensor_1, tensor_2)
278278

279-
array = np.random.rand(5, 3)
279+
rng = np.random.default_rng(seed=123456)
280+
array = rng.random((5, 3))
280281
_gradcheck.check_finite_differences(function, array, parameter="g")
281282

282283

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

290-
array = torch.rand(5, 3, dtype=torch.float64)
291+
rng = torch.Generator()
292+
rng.manual_seed(123456)
293+
array = torch.rand(5, 3, dtype=torch.float64, generator=rng)
291294
_gradcheck.check_finite_differences(function, array, parameter="g")

0 commit comments

Comments
 (0)