Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overflow of uint datatypes just happens silently - should raise warning/error? #11

Open
KevinMcCarthyAtIDM opened this issue Dec 11, 2024 · 0 comments

Comments

@KevinMcCarthyAtIDM
Copy link
Collaborator

Looking back on issue #6 - I spent time trying to track down why my SIS model wasn't doing what I thought, and it turned out to be overflow of the uint8 datatype.
So closing that issue, because it is solved/never a bug, but I'm wondering whether we want to implement some checking to prevent this issue downstream.

Unfortunately, numpy won't do this for us - numpy should raise overflow errors for scalar variables, but the team has decided not to implement overflow checking for numpy integer arrays.
"Unlike true floating point errors (where the hardware FPU sets a flag whenever it does an atomic operation that overflows), we need to implement the integer overflow detection ourselves. We do it on the scalars, but not arrays because it would be too slow to implement for every atomic operation on arrays." link

Interesting to me though, is that the overflow was happening in this line:
itimers[i] = np.maximum(np.uint8(1), np.uint8(np.ceil(np.random.exponential(inf_mean)))) I feel like an error should have been raised at the casting point np.uint8(np.ceil(np.random.exponential(inf_mean))), but wasn't.

Either way, would be good to have some checking eventually, as this was a bit of an annoying rabbit hole. Checking probably made easier by first addressing #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant