Open wyli opened 1 year ago
(cc @ericspod @john-zielke-snkeos follow-up of the discussions in #6854, self.R
and RandomState
is currently preferred over np.random.*
, this ticket is to track the issue.
e.g. preferred usage: https://github.com/Project-MONAI/MONAI/blob/8aabdc917bbf059800968906af22c62b79a6c763/monai/data/synthetic.py#L65)
If we wanted to first change the usages of np.random.*
to use a RandomState
then migrate in the future to Generator
we could do the following:
np.random.*
in transforms to use self.R
. This will change some expected deterministic behaviour but would be more reproducible. RandomState
object as an argument and use that, defaulting to np.random
if none is provided. This would cover most use cases with minimal addition. @wyli 's code snippet is probably the technique to use for this.apps/*
and auto3dseg
ask contributors what they would want to do, mentioning we're trying to tighten up the implementation with an eye to future migration.We do need to have a more considered discussion about what to do about migration at some point, either we move to Generator
or we do implement our own class to replace RandomState
usage.
So it seems like there is no need to migrate those immediately, but just wanted to mention that here. Since there are around ~390 usages in tests I am not listing them here.
I found usages using the following bash command:
find . -name "*.py" -exec grep -o -H -n -E 'np.random.\w+' {} \; | grep -v "RandomState" | sort | uniq
Originally posted by @john-zielke-snkeos in https://github.com/Project-MONAI/MONAI/issues/6854#issuecomment-1682375125