Skip to content

Commit

Permalink
Instrument broadening test: fix trouble with Numpy versions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajjackson committed Oct 24, 2022
1 parent 7c640d5 commit a1e73cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests_and_analysis/test/euphonic_test/test_broadening.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a1e73cc

Please sign in to comment.