This is not with named array dimensions, but with only JaggedArrays, masked selection is possible:
jarr_2d = aw.fromiter([[np.array([0, 1, 2]), np.array([3, 4, 5])],
[np.array([6, 7]), np.array([8, 9])]])
# <JaggedArray [[[0 1 2] [3 4 5]] [[6 7] [8 9]]] at 0x7fc9c7c4e750>
jarr_2d_mask = aw.fromiter([[np.array([False, True, False]), np.array([True, True, False])],
[np.array([True, True]), np.array([True, False])]])
# <JaggedArray [[[False True False] [True True False]] [[True True] [True False]]] at 0x7fc9c7c1e590>
jarr_2d[jarr_2d_mask]
# <JaggedArray [[[1] [3 4]] [[6 7] [8]]] at 0x7fc9c7c5b690>
Not sure if this code is efficient? Especially compared to fancy indexing with only Numpy arrays?
Answer from NumesSanguis on Stack OverflowAwkward-array
awkward-array.org › doc › main › reference › generated › ak.mask.html
ak.mask — Awkward Array 2.13.0 documentation
mask (array of booleans) – The mask that overlays elements in the array with None.
Awkward-array
awkward-array.org › doc › main › user-guide › how-to-filter-cut-mask.html
How to filter arrays: cutting vs. masking — Awkward Array 2.9.0 documentation
The problem was that the two arrays’ shapes changed differently; instead, we’ll slice them in such a way that their shapes don’t change at all. The ak.mask() function uses a boolean array like a slice, but takes values that line up with False and returns None instead of removing them.
Readthedocs
awkward-array.readthedocs.io › en › latest › _auto › ak.mask.html
ak.mask — Awkward Array documentation
>>> ak.mask(array, good) <Array [None, 1, None, 3, ...
Awkward-array
awkward-array.org › doc › 2.1 › user-guide › how-to-filter-cut-mask.html
How to filter arrays: cutting vs. masking — Awkward Array 2.1.4 documentation
This is a stub: I intend to write this article, but haven’t yet · If you need it soon, create an issue saying so and I’ll make it a higher priority
Awkward-array
awkward-array.org › doc › stable › reference › generated › ak.mask.html
ak.mask — Awkward Array 2.14.0 documentation
An array with elements replaced by None where the mask condition fails.
Awkward-array
awkward-array.org › doc › main › user-guide › how-to-filter-masked.html
How to filter with arrays containing missing values — Awkward Array 2.9.0 documentation
Setting mask_identity=True yields the identity value for the reducer instead of None when reducing empty lists. From the above examples of ak.argmax(), we can see that the identity for the ak.argmax() is -1: What happens if we try and use the array produced with mask_identity=False to index ...
Cms-opendata-workshop
cms-opendata-workshop.github.io › workshop2022-lesson-cpp-root-python › 08-awkward
Using awkward arrays to analyze HEP data – ROOT with C++ and python
August 2, 2022 - Note that we are making use of boolean arrays to perform masking when we type mass_fast[qtot==0]. While we cannot teach you everything about awkward, we hope we’ve given you a basic introduction to what it can do and where you can find more information so that you can quickly process the ...
Starred by 214 users
Forked by 38 users
Languages: Python 63.7% | Jupyter Notebook 36.3%
Awkward-array
awkward-array.org › doc › main › reference › generated › ak.contents.ByteMaskedArray.html
ak.contents.ByteMaskedArray — Awkward Array 2.8.5 documentation
Defined in awkward.contents.bytemaskedarray on line 58. class ak.contents.ByteMaskedArray(self, mask, content, valid_when, *, parameters=None)# The ByteMaskedArray implements an ak.types.OptionType with two aligned buffers, a boolean mask and content. At any element i where mask[i] == valid_when, the value can be found at content[i]. If mask[i] != valid_when, the value is missing (None). This is equivalent to NumPy’s masked arrays if valid_when=False.
Awkward-array
awkward-array.org › doc › 2.0 › user-guide › how-to-filter-cut-mask.html
How to filter arrays: cutting vs. masking — Awkward Array 2.0.4 documentation
This is a stub: I intend to write this article, but haven’t yet · If you need it soon, create an issue saying so and I’ll make it a higher priority
GitHub
github.com › scikit-hep › awkward › discussions › 584
Masking and flattening (using an argmax as a integer-array slice) · scikit-hep/awkward · Discussion #584
December 9, 2020 - I have some problems understanding how to "flatten" nested arrays/records when applying masks. I think it's best explained with an actual use-case (with reduced complexity). Given a set of events (in this case 3), each event contains a variable lengths of particle tracks where I want to pick exactly one with the highest likelihood (lik). from skhep_testdata import data_path import uproot import awkward as ak f = uproot.open(data_path("uproot-issue431b.root")) # grab the tracks of the first three events and only the lik-parameter for simplicity tracks = f["E/Evt/trks"].arrays(["lik"], aliases={"lik": "trks.lik"})[:3]
Author: scikit-hep
Awkward-array
awkward-array.org › doc › main › reference › generated › ak.Array.html
ak.Array — Awkward Array 2.13.0 documentation
>>> ak.mask(array, ak.num(array) > 1)[:, 0] <Array [1.1, None, 4.4, None, None, 7.7] type='6 * ?float64'> >>> ak.mask(array, ak.num(array) > 1)[:, 1] <Array [2.2, None, 5.5, None, None, 8.8] type='6 * ?float64'>
Awkward-array
awkward-array.org › doc › 2.1 › getting-started › index.html
Getting started — Awkward Array 2.1.4 documentation
Awkward Array extends the rich indexing syntax used by NumPy to support named fields and ragged indexing: >>> array = ak.Array([ ... [1, 2, 3], ... [6, 7, 8, 9] ... ]) >>> is_even = (array % 2) == 0 >>> array[is_even].to_list() <Array [[2], [6, 8]] type='2 * var * int64'> Meanwhile, the ...
Awkward-array
awkward-array.org › doc › main › _sources › user-guide › how-to-convert-numpy.md.txt
--- jupytext: text_representation: extension: .md format_name: myst
Masked arrays can only have missing numbers, not missing lists, so missing lists are expanded into lists of missing numbers.
Awkward-array
awkward-array.org › doc › 2.4 › getting-started › index.html
Getting started — Awkward Array 2.4.10 documentation
Awkward Array extends the rich indexing syntax used by NumPy to support named fields and ragged indexing: >>> array = ak.Array([ ... [1, 2, 3], ... [6, 7, 8, 9] ... ]) >>> is_even = (array % 2) == 0 >>> array[is_even].to_list() <Array [[2], [6, 8]] type='2 * var * int64'> Meanwhile, the ...
Awkward-array
awkward-array.org › doc › 2.3 › getting-started › index.html
Getting started — Awkward Array 2.3.3 documentation
Awkward Array extends the rich indexing syntax used by NumPy to support named fields and ragged indexing: >>> array = ak.Array([ ... [1, 2, 3], ... [6, 7, 8, 9] ... ]) >>> is_even = (array % 2) == 0 >>> array[is_even].to_list() <Array [[2], [6, 8]] type='2 * var * int64'> Meanwhile, the ...
Readthedocs
awkward-array.readthedocs.io › en › latest › ak.layout.ByteMaskedArray.html
Readthedocs
Awkward Array is a library for nested, variable-sized data, including arbitrary-length lists, records, mixed types, and missing data, using NumPy-like idioms.