Skip to content

Commit

Permalink
Use an explicit rng to avoid failures from random deviations
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed May 16, 2024
1 parent 500f50d commit ffdabb9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_chromatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3234,6 +3234,7 @@ def test_save_photons():
# possible types and all possible paths through the various drawImage and shoot functions.
# This test tries to be more comprehensive on that front.

rng = galsim.BaseDeviate(1234)
star_sed = galsim.SED('vega.txt', wave_type="nm", flux_type="fphotons")
bandpass = galsim.Bandpass("LSST_r.dat", wave_type="nm")

Expand Down Expand Up @@ -3271,7 +3272,7 @@ def test_save_photons():
obj = obj.withFlux(flux, bandpass)
image = obj.drawImage(bandpass=bandpass, method="phot",
n_photons=flux, save_photons=True,
scale=0.05, nx=32, ny=32)
scale=0.05, nx=32, ny=32, rng=rng)
assert hasattr(image, 'photons')
assert len(image.photons) == flux
print(np.sum(image.photons.flux))
Expand All @@ -3283,7 +3284,7 @@ def test_save_photons():
# Sometimes there is a different path when n_photons is not given, so check that too.
image = obj.drawImage(bandpass=bandpass, method="phot",
save_photons=True,
scale=0.05, nx=32, ny=32)
scale=0.05, nx=32, ny=32, rng=rng)
assert hasattr(image, 'photons')
print(np.sum(image.photons.flux))
assert np.allclose(np.sum(image.photons.flux), flux, rtol=0.1)
Expand Down

0 comments on commit ffdabb9

Please sign in to comment.