Skip to content

Aurora int16 safety#213

Open
lgarrison wants to merge 3 commits into
aurorafrom
aurora-int16-safety
Open

Aurora int16 safety#213
lgarrison wants to merge 3 commits into
aurorafrom
aurora-int16-safety

Conversation

@lgarrison

Copy link
Copy Markdown
Member

Addressing the 16-bit int issue found by @deisenstein and @xjka (I think).

In Daniel's words:

E.g., logs[‘length’] is uint16.  On my computer, a sum of that happily promoted and returned a sane value.  On Alex’s, it just spilled 15 bits.

Hopefully, this was "just" the behavior change between NumPy 1 & 2 when mixing int16 with Python int. That should be fixed here by requiring NumPy 2.

But there's always a more general risk of downstream users tripping on int overflow or unsigned int wraparound, especially in 16 bits. So here we're also promoting [u]int16 and uint32 to int32 (with an overflow check as needed). It costs a bit of memory, but is probably worth the safety.

I changed any "math-able" fields: dist_bin and count (for healstruct), and mult, timestep, mult_sec, length (for maplog). I left bitflag fields alone. PID has 3 uint16 and is kind of a middle ground since the Lagrangian indices are technically math-able, but I left it unpromoted. I can imagine a lot of applications want to key off, or sort by, PID, and a 96-bit key would genuinely hurt performance.

lgarrison and others added 3 commits June 8, 2026 12:55
For consistent [u]int16 semantics.
Just trying to get ahead of any downstream 16-bit int overflow/wraparound
issues.
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

Successfully merging this pull request may close these issues.

1 participant