question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

index method seems to always return zero when the element used is an awkward1 Array

See original GitHub issue

I have been trying to use the index method, but it seems to always return 0.

Here is how I proceed:


import awkward1 as ak1

test = ak1.Array([[[1, 2, 3], [1, 2, 3], [1]],
                  [[0], [1, 2, 3]],
                  [[0], [1, 2, 3], [0], [1, 2, 3], [1, 2, 3]]])

print(test[1].index(ak1.Array([1, 2, 3])))
# 0
print(test[2].index(ak1.Array([1, 2, 3])))
# 0

any ideas why this is happening?

Thank you.

ping @tamasgal

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tamasgalcommented, Apr 21, 2020

Yep, the catch is really that the truthiness of an array is not an all(...).

@zinebaly I’d recommend to implement a numba JITted function, that should be fairly straight forward.

1reaction
tamasgalcommented, Apr 21, 2020

Yep, the catch is really that the truthiness of an array is not an all(...).

@zinebaly I’d recommend to implement a numba JITted function, that should be fairly straight forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ak.Array — Awkward Array 2.0.0 documentation
An integer selects one element. Like Python/NumPy, it is zero-indexed: 0 is the first item, 1 is the second, etc. Negative indexes count...
Read more >
Unintuitive slicing behaviour when slicing with Arrays #370
Slicing by an array of indices would be very handy but currently fails (or is unreliable). Minimal working example taken (mostly based on ......
Read more >
Error when using an awkward array with an index array
It's a generic iterable, and the constructor falls back to ak.from_iter. On your main question, the reason that arr doesn't slice values is ......
Read more >
ak.behavior — Awkward Array 2.0.0 documentation
The approach taken by the Awkward Array library is to encode very little interpretation into the data themselves and apply an interpretation as...
Read more >
4. Pointers and Arrays - Understanding and Using C ... - O'Reilly
A one-dimensional array is a linear structure. It uses a single index to access its members. The following is a declaration of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found