-
Notifications
You must be signed in to change notification settings - Fork 120
ak.where errors if array has None #3138
Copy link
Copy link
Closed
Labels
bug (unverified)The problem described would be a bug, but needs to be triagedThe problem described would be a bug, but needs to be triaged
Description
Version of Awkward Array
2.6.5
Description and code to reproduce
In version 2.0.7 I could do something like this:
import numpy as np
import awkward as ak
a = np.arange(12.).reshape(3,4)
a[2,3] = np.nan
b = ak.nan_to_none(a)
ak.where(b == ak.max(b))With a result like this:
(<Array [2] type='1 * int64'>, <Array [2] type='1 * int64'>)In version 2.6.4 and 2.6.5 I get an error like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/_dispatch.py", line 64, in dispatch
next(gen_or_result)
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/operations/ak_where.py", line 55, in where
return _impl1(condition, mergebool, highlevel, behavior, attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/operations/ak_where.py", line 74, in _impl1
out = layout.backend.nplike.nonzero(layout.to_backend_array(allow_missing=False))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/contents/content.py", line 1020, in to_backend_array
return self._to_backend_array(allow_missing, backend)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/contents/regulararray.py", line 1277, in _to_backend_array
out = self._content._to_backend_array(allow_missing, backend)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/timdiller/test_environment/lib/python3.12/site-packages/awkward/contents/indexedoptionarray.py", line 1609, in _to_backend_array
raise ValueError(
ValueError: Content.to_nplike cannot convert 'None' values to np.ma.MaskedArray unless the 'allow_missing' parameter is set to True
This error occurred while calling
ak.where(
<Array [[False, False, False, False], ..., [...]] type='3 * 4 * ?bool'>
)
There is no place I can find to pass allow_missing.
This seems to be something different from #3098.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug (unverified)The problem described would be a bug, but needs to be triagedThe problem described would be a bug, but needs to be triaged