From a9fb0e1369e02362eb9ad42b5b4b338db0dd7f80 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca <14138589+paskino@users.noreply.github.com> Date: Sun, 21 Jul 2024 19:06:04 +0100 Subject: [PATCH] fix seed for LSVRG test --- Wrappers/Python/test/test_approximate_gradient.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Wrappers/Python/test/test_approximate_gradient.py b/Wrappers/Python/test/test_approximate_gradient.py index 86044a4759..c8ad954953 100644 --- a/Wrappers/Python/test/test_approximate_gradient.py +++ b/Wrappers/Python/test/test_approximate_gradient.py @@ -531,4 +531,14 @@ def test_LSVRG_toy_example_store_gradients(self): self.assertNumpyArrayAlmostEqual( alg_stochastic.x.as_array(), u_cvxpy.value, 3) self.assertNumpyArrayAlmostEqual( - alg_stochastic.x.as_array(), b.as_array(), 3) \ No newline at end of file + alg_stochastic.x.as_array(), b.as_array(), 3) + + def test_sampler_out_of_range(self): + def g(index): + return -2 + bad_sampler = Sampler.from_function(12,g) + f = self.stochastic_estimator([self.f]*10, bad_sampler, seed=25) + with self.assertRaises(IndexError): + f.gradient(self.initial) + f.gradient(self.initial) + \ No newline at end of file