Skip to content

Array indexing after mask: bug or feature? #622

Answered by jpivarski
Duchstf asked this question in Q&A
Discussion options

You must be logged in to vote

Could you give more details, like what the type of truth_x_target and mask are, and what you expected?

When I tried an example, I didn't find anything unexpected:

>>> array = ak.Array([[0.0, 1.1, 2.2], [], [3.3, 4.4], [5.5], [6.6, 7.7, 8.8, 9.9]])
>>> array.type
5 * var * float64
>>> array.tolist()
[[0.0, 1.1, 2.2], [], [3.3, 4.4], [5.5], [6.6, 7.7, 8.8, 9.9]]

For a singly jagged array of numbers like this, there are two possible masks: flat booleans and (singly) jagged booleans. Here's an example of a flat boolean mask:

>>> mask1 = ak.num(array) > 1
>>> mask1.type
5 * bool
>>> mask1.tolist()
[True, False, True, False, True]

and here's an example of a jagged boolean mask:

>>> mask2 = array *

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Duchstf
Comment options

You must be logged in to vote
2 replies
@jpivarski
Comment options

@Duchstf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants