Closed sjforeman closed 2 months ago
dtype
is popped from kwargs
here:
https://github.com/radiocosmology/draco/blob/65808dd4ad3f627c8c2e6127bce32b218cffe6ac/draco/util/random.py#L385
And then the kwargs
, without dtype
is passed to the numpy method here:
https://github.com/radiocosmology/draco/blob/65808dd4ad3f627c8c2e6127bce32b218cffe6ac/draco/util/random.py#L422
I've played around with it a bit. It appears that rng.standard_normal
does not try to use the dtype of out
, so if dtype
isn't provided as an argument (which it isn't, as Don points out) it will default to np.float64
regardless of the dtype of out
. To fix this, we just need to provide the dtype argument - I'll make a quick PR
When I try to run
GaussianNoiseDataset
with a fresh virtual environment on cedar, I get a strange error (after fixing a different error with https://github.com/radiocosmology/draco/pull/287). Here are some relevant lines from the log (they might be out of order, since they were printed by each of the many threads there were running, but hopefully they convey the rough message):Here is what I think is going on:
numpy.random.Generator.standard_normal
(https://numpy.org/doc/stable/reference/random/generated/numpy.random.Generator.standard_normal.html) is being called with anout
argument, and the dtype of theout
argument isnp.float32
, but the routine expectsnp.float64
. However, in tracing through where this is called in draco, it seems like adtype=np.float32
is also being supplied, so I'm not sure why the error is occurring.Tracing through the code:
random.complex_normal
is called here: https://github.com/radiocosmology/draco/blob/f3c2650cf201f1803fe2335f339a5cbad7346c78/draco/synthesis/noise.py#L107dset
isnp.complex64
, sincedset
is the vis dataset of a SiderealStream (https://github.com/radiocosmology/draco/blob/b2a701a58f99f2db5b3b1024096616059f4c2bf1/draco/core/containers.py#L1186).random.complex_normal
detects this dtype, and callsrng.standard_normal()
withdtype=np.float32
: https://github.com/radiocosmology/draco/blob/65808dd4ad3f627c8c2e6127bce32b218cffe6ac/draco/util/random.py#L87-L103rng
is aMultithreadedRNG
(https://github.com/radiocosmology/draco/blob/65808dd4ad3f627c8c2e6127bce32b218cffe6ac/draco/util/random.py#L267), and it looks like thedtype=np.float32
argument should be correctly propagated through (although I haven't attempted a full line-by-line examination of what happens in this class).Some help in finishing this detective work would be much appreciated!