tapios / risk-networks

Code for risk networks: a blend of compartmental models, graphs, data assimilation and semi-supervised learning
Other
2 stars 2 forks source link

Ambiguous length computed in DataAssimilator.sum_to_one #115

Closed dburov190 closed 4 years ago

dburov190 commented 4 years ago

Here: https://github.com/dburov190/risk-networks/blob/8d8bbfc0b61621d9ef48df22b33251dd8f386b64/epiforecast/data_assimilator.py#L314

it should be

if observation.obs_state.size > 0:

instead

odunbar commented 4 years ago

I don't see how it is ambiguous. But if you would like to change it for better consistency, your suggestion is fine

dburov190 commented 4 years ago

well, in the current version a new boolean array is computed first, and then, regardless of the values of observation.obs_states, the length of that array (equal to the length of the original one) is returned

then, the integer is implicitly converted to a boolean: if it's 0, then False, if greater then zero, then True

So, there are extra mental operations you have to perform in order to understand what's going on (: and extra memory allocation, which is unnecessary here