Skip to content

fix: improve type consistency in to_packed for num_none#3538

Merged
ianna merged 9 commits intomainfrom
ikrommyd/numpy-2.3-compatibility
Jun 13, 2025
Merged

fix: improve type consistency in to_packed for num_none#3538
ianna merged 9 commits intomainfrom
ikrommyd/numpy-2.3-compatibility

Conversation

@ianna
Copy link
Copy Markdown
Member

@ianna ianna commented Jun 12, 2025

This PR ensures that the variable num_none in the to_packed method consistently holds a plain Python int, regardless of the nplike backend (NumPy, CuPy, JAX, etc.). This prevents potential type issues or unexpected behavior when performing downstream operations that expect a native int.

@ianna
Copy link
Copy Markdown
Member Author

ianna commented Jun 12, 2025

import awkward as ak
import numpy as np

content = ak.contents.NumpyArray(np.array([0.0, 1.1, 2.2, 3.3, 4.4]))
index = ak.index.Index64(np.array([2, 2, 0, -1, 4], dtype=np.int64))
array = ak.contents.IndexedOptionArray(index, content)
array.to_packed()

Copy link
Copy Markdown
Member Author

@ianna ianna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the only part which is relevant here is the change in the IndexedOptionArray.

@ianna ianna changed the title fix: numpy 2.3 compatibility fix: improve type consistency in to_packed for num_none Jun 13, 2025
@ianna ianna merged commit 3beae4c into main Jun 13, 2025
44 checks passed
@ianna ianna deleted the ikrommyd/numpy-2.3-compatibility branch June 13, 2025 06:39
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.

3 participants