Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ak.where errors if array has None #3138

Open
timdiller opened this issue Jun 3, 2024 · 0 comments
Open

ak.where errors if array has None #3138

timdiller opened this issue Jun 3, 2024 · 0 comments
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@timdiller
Copy link

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.

@timdiller timdiller added the bug (unverified) The problem described would be a bug, but needs to be triaged label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant