From 4f290667cd5c1360137c12b489b6f111b34f75bd Mon Sep 17 00:00:00 2001 From: chris-langfield Date: Tue, 27 Feb 2024 17:26:17 +0000 Subject: [PATCH] add seed to calibration test --- tests/test_poisson_calibrate.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_poisson_calibrate.py b/tests/test_poisson_calibrate.py index 34d9633..8e18c0b 100644 --- a/tests/test_poisson_calibrate.py +++ b/tests/test_poisson_calibrate.py @@ -3,6 +3,8 @@ import pytest DEBUG = False +SEED = 7916 +rng = np.random.default_rng(SEED) def make_fake_movie(gains=[10], offsets=[1], shape=(100, 10, 10), min_rate=1, max_rate=5, dtype="int16"): assert isinstance(shape, tuple) @@ -15,13 +17,13 @@ def make_fake_movie(gains=[10], offsets=[1], shape=(100, 10, 10), min_rate=1, ma for x_ind in range(x): for y_ind in range(y): # We pick a random rate for each pixel - rate = np.random.uniform(min_rate, max_rate) + rate = rng.uniform(min_rate, max_rate) # We pick a random gain and offset for each pixel - gain = gains[np.random.randint(0, nb_gains)] - offset = offsets[np.random.randint(0, nb_gains)] + gain = gains[rng.integers(0, nb_gains)] + offset = offsets[rng.integers(0, nb_gains)] - output_array[:, x_ind, y_ind] = gain*np.random.poisson(rate, size=times)+offset + output_array[:, x_ind, y_ind] = gain*rng.poisson(rate, size=times)+offset return output_array