Skip to content

fix(python/geometry): Prevent cast_to_single from casting integers to float32 (#678)#750

Merged
AnderBiguri merged 1 commit into
CERN:masterfrom
Paramveersingh-S:fix-cast-to-single
Jun 23, 2026
Merged

fix(python/geometry): Prevent cast_to_single from casting integers to float32 (#678)#750
AnderBiguri merged 1 commit into
CERN:masterfrom
Paramveersingh-S:fix-cast-to-single

Conversation

@Paramveersingh-S

Copy link
Copy Markdown
Contributor

Description

Fixes issue #678 where Geometry.cast_to_single() forcefully cast integers and lists of integers into np.float32, which inadvertently corrupts integer-based attributes and crashes memory allocations in algorithms like sart.

Changes made

  • Added a robust dtype check using np.issubdtype to gracefully intercept and ignore pure integers and arrays of integers.
  • Floats and float arrays are still correctly cast to single precision.
  • No changes required to the exclude_from_cast hardcoded array, preventing this issue from occurring on any custom integer variables users might attach to the Geometry object.

@AnderBiguri

Copy link
Copy Markdown
Member

ah thanks! I assume this is one of those numpy 2.4 caused issues, which is why I didn't catch it.

@AnderBiguri AnderBiguri merged commit 054e1ac into CERN:master Jun 23, 2026
2 checks passed
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.

2 participants