swagnercarena / paltas

Conduct simulation-based inference on strong gravitational lensing systems.
MIT License
13 stars 12 forks source link

Reproducible images using a sequence of seeds #34

Closed JelleAalbers closed 2 years ago

JelleAalbers commented 2 years ago

This PR makes it possible to reproduce datasets, and individual images from training datasets (without generating all previous images). This should be useful e.g. to generate convergence maps, or the list of subhalo masses and positions, for specific images in datasets we are interested in.

Paltas already allows you to set the numpy random seed via the config. However, it also draws some random numbers from numba, which uses a separate random number generator. Thus, setting the seed in paltas' config does not yet result in predictable images. This also means some of the unit tests are not fully deterministic.

After this PR:

We're not exactly following best practice with random number generators: current wisdom avoids np.seed and instead makes separate random generator instances and passes them around the code. That would be a much bigger change affecting the entire code though.

Two minor changes smuggled in:

swagnercarena commented 2 years ago

Looks great!