From a1e73cc1dd1839fc5cfc2bfd85922e89c5b37091 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Mon, 24 Oct 2022 17:49:09 +0100 Subject: [PATCH] Instrument broadening test: fix trouble with Numpy versions Figure out which versions of the random generators both a) work b) don't raise deprecation warnings for our range of supported numpy versions. What's especially annoying is that RandomState isn't even the current recommended way of doing this; according to Numpy docs the best-practice is now `rng = np.random.default_rng(seed)`, with the resulting Generator providing random() and integers() methods. But that doesn't exist in older versions, so we'll probably want to migrate this in future. --- tests_and_analysis/test/euphonic_test/test_broadening.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests_and_analysis/test/euphonic_test/test_broadening.py b/tests_and_analysis/test/euphonic_test/test_broadening.py index 59fe42b96..3cc7e4518 100644 --- a/tests_and_analysis/test/euphonic_test/test_broadening.py +++ b/tests_and_analysis/test/euphonic_test/test_broadening.py @@ -27,7 +27,7 @@ def test_polynomial_close_to_exact(): bin_width = bins[1] - bins[0] x = (bins[1:] + bins[:-1]) / 2 y = np.zeros_like(x) - y[rng.random_integers(0, len(x), 20)] = rng.random(20) + y[rng.randint(0, len(x), 20)] = rng.rand(20) sigma = 2. exact = gaussian_filter(y, (sigma / bin_width), mode='constant')