Closed nraffuzz closed 9 months ago
Mmm, weights
should always be an array; if it's not, it's a bug. That field is initialized by get_map_making_weights
, which might fail if obs.net_ukrts
is not an array but a scalar.
May you please post here how you create the observations in the code it's failing? We should add an additional check that prevents floats from being passed, but first let's check where the problem originates.
I specifically stated obs.net_ukrts = 2.2
, so as a scalar. Indeed, if passed as an array the issue is solved, thanks!
Could it be useful to add something like?
if type(obs.net_ukrts) == float or int:
obs.net_ukrts = obs.net_ukrts * np.ones(obs.n_detectors)
Yes, that would be good, but it's better to write the test in the following way:
if isinstance(obs.net_ukrts, (float, int)):
…
May you open a PR and add this line?
I believe this can be closed, as PR #272 fixed the issue. Feel free to reopen if you think there is still something that doesn't work.
While creating an Obsevation object (and filling it) I tried to apply the built-in destriper, this is the used code:
but I get the following error:
The TypingError is due to line 375 of destriper.py, where
weights[det_idx]
is called butweights
is a float64 and not an array, and it's inside the_accumulate_nobs_matrix
function. I noticed that_accumulate_nobs_matrix
function should acceptweights: npt.ArrayLike
, but the passed object is a float number, at line 460 of destriper.py, whereweights=cur_obs.destriper_weights
. If I try to printtype(obs.destriper_weights)
I getfloat
.