pysal / pointpats

Planar Point Pattern Analysis in PySAL
https://pysal.org/pointpats/
BSD 3-Clause "New" or "Revised" License
84 stars 27 forks source link

All random generation should be settable with numpy random generator #146

Open paucodeici opened 3 months ago

paucodeici commented 3 months ago

I am not aware of where exactly there are call to numpy.random but it should be call to some random number generator fed in the function.

Typically pointpats.random.poisson( rng=np.random.default_rng(???)) or specify a seed or something

Can do the change but I am not aware if it would break anything or would be long and painful change.

martinfleis commented 3 months ago

Fully agree. Right now we call individual functions from numpy.random inside our functions like here https://github.com/pysal/pointpats/blob/8c2010830322e9d89463422c8deebbcaab645503/pointpats/random.py#L240 or here https://github.com/pysal/pointpats/blob/8c2010830322e9d89463422c8deebbcaab645503/pointpats/random.py#L150-L151

If you want to fix the random seed, you need to use the global numpy.random.seed. We should transition towards random generator support. The change should not be too complicated. We just need to expose rng and use methods on rng to draw random samples instead of current functions.