awkward.fromiter is the one function that was allowed to be written in Python for loops, and hence it is designated to be slow. The function you want for turning regular NumPy arrays into JaggedArrays that happen to have uniform counts is JaggedArray.fromregular. That ought to be considerably faster.
Meanwhile, your original issue is an example of an inconsistency in Awkward 0.x. In Awkward 1.x, the behavior of Awkward Arrays that happen to be regular and NumPy arrays with the same logical meaning are identical. You might want to consider awkward1.from_awkward0 in the awkward1 library to try it out. (It's a separate library because the interface is a little different and I don't want to break anyone's analysis!)
Awkward-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.8.2 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-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 › how-to-filter-cut-mask.html
How to filter arrays: cutting vs. masking
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
Readthedocs
awkward-array.readthedocs.io › en › latest › ak.layout.ByteMaskedArray.html
ak.layout.ByteMaskedArray — Awkward Array documentation
The ByteMaskedArray implements an ak.types.OptionType with two aligned arrays, a boolean mask and content.
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
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 ...
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 › _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 ...