Skip to content

fix: allow arrays with Nones in single argument usage of ak.where#3563

Merged
ianna merged 6 commits intomainfrom
ikrommyd/allow-missing-in-ak-where
Aug 26, 2025
Merged

fix: allow arrays with Nones in single argument usage of ak.where#3563
ianna merged 6 commits intomainfrom
ikrommyd/allow-missing-in-ak-where

Conversation

@ikrommyd
Copy link
Collaborator

@ikrommyd ikrommyd commented Jun 28, 2025

Fixes #3138

This used to use ak.operations.to_numpy which allowed Nones to go through until #2757 changed it to use to_backend_array with allow_missing=False. I don't think there is any harm in setting allow_missing=True here.

@ikrommyd ikrommyd changed the title allow missing=True in single argument ak.where fix: allow missing=True in single argument ak.where Jun 28, 2025
@ikrommyd ikrommyd changed the title fix: allow missing=True in single argument ak.where fix: allow arrays with Nones in single argument usage of ak.where Jun 28, 2025
@ikrommyd ikrommyd requested review from ianna and pfackeldey June 29, 2025 00:14
@ikrommyd
Copy link
Collaborator Author

All these tests error on main with ValueError: Content.to_nplike cannot convert 'None' values to np.ma.MaskedArray unless the 'allow_missing' parameter is set to True

@pfackeldey
Copy link
Collaborator

This change makes sense to me, but I seem to not understand yet why it was changed in #2757? Maybe there was a reason for this?

@ikrommyd
Copy link
Collaborator Author

ikrommyd commented Jun 30, 2025

This change makes sense to me, but I seem to not understand yet why it was changed in #2757? Maybe there was a reason for this?

@agoose77 is there a reason to not allow missing values for the single argument case of ak.where? I’m tagging since that was your PR.

@ikrommyd
Copy link
Collaborator Author

Discussed briefly with Angus at SciPy about this and the reasoning was probably that this was the safest thing to do when .attrs was added. However, .nonzero() seems to always returns an array with integers and it doesn't matter if the numpy array is masked or not so awkward can always convert it into an awkward array again so it should be safe to enable this.

@ianna ianna added the pr-next-release Required for the next release label Aug 21, 2025
Copy link
Member

@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.

@ikrommyd - Thanks for adding the tests! They look visually identical to NumPy on my end. It’d be nice to also have a direct comparison with NumPy.

@ikrommyd
Copy link
Collaborator Author

@ikrommyd - Thanks for adding the tests! They look visually identical to NumPy on my end. It’d be nice to also have a direct comparison with NumPy.

added that too! 😃

@ianna
Copy link
Member

ianna commented Aug 26, 2025

@ikrommyd - Thanks for adding the tests! They look visually identical to NumPy on my end. It’d be nice to also have a direct comparison with NumPy.

added that too! 😃

Thanks @ikrommyd - have you read my message on Slack? Thanks.

@ikrommyd
Copy link
Collaborator Author

ikrommyd commented Aug 26, 2025

Oh sorry. I just did no

@ikrommyd - Thanks for adding the tests! They look visually identical to NumPy on my end. It’d be nice to also have a direct comparison with NumPy.

added that too! 😃

Thanks @ikrommyd - have you read my message on Slack? Thanks.

Oh sorry. I just did now. I thought your comment here was a request to make this change. My bad.

Copy link
Member

@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.

@ikrommyd - Thanks! Please, see my comment above.

Copy link
Member

@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.

@ikrommyd - Thanks!

@ianna ianna merged commit 376fc4a into main Aug 26, 2025
46 checks passed
@ianna ianna deleted the ikrommyd/allow-missing-in-ak-where branch August 26, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-next-release Required for the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ak.where errors if array has None

3 participants