Questions tagged [awkward-array]

Python toolkit for manipulating nested data structures as though they were NumPy arrays.

awkward is a Python library for computing array-at-a-time ("vectorized") operations on nested and irregular-length data structures. The interface resembles as much as possible and is implemented using NumPy.

It is intended as an interactive analysis toolkit for datasets that can't be reduced to rectilinear arrays. For example, a dataset of extrasolar planets can have arbitrarily many planets per star, and each planet has several attributes. A dataset of particle physics collisions contains collision event records, each with arbitrarily many electron records, muon records, photon records, etc. Instead of looping over these constructs in a general purpose language, awkward-array allows the user to slice them like (irregular) multidimensional arrays, project through columns, sum over variable-sized sets, etc.

As an artificial example, consider this structure:

complicated = awkward.fromiter(
    [[1.21, 4.84, None, 10.89, None],
     [19.36, [30.25]],
     [{"x": 36, "y": {"z": 49}}, None, {"x": 64, "y": {"z": 81}}]
    ])

Once in awkward form, we can apply Numpy operations, such as ufuncs:

numpy.sqrt(complicated).tolist()
# [[1.1, 2.2, None, 3.3000000000000003, None],
#  [4.4, [5.5]],
#  [{'x': 6.0, 'y': {'z': 7.0}}, None, {'x': 8.0, 'y': {'z': 9.0}}]]

awkward-array interfaces with , , , , and .

68 questions
0
votes
0 answers

Unpacking a variable number of 2D jagged numpy tuples (findcontours())

I'm using cv2.findcontours() which outputs a variable number of variable length Nx2 tuples. For example, converting the tuples to a list: (array([[[100, 100]], ..., [[200, 200]]], dtype=int32), array([[[50, 50]], ..., [[300, 300]]],…
0
votes
0 answers

Rebinning a TH2 histogram from ROOT using uproot and then plot it with matplotlib

I am able to extract a TH2 histogram from ROOT using the h = f[...].to_numpy() of uproot. This I can then plot with mplhep as a hist2dplot(h). However, I have the problem that I would like to rebin the original histogram and then plot this. I could…
nyw
  • 195
  • 2
  • 11
0
votes
1 answer

TLorentz vector in Uproot 4

I try to use TLorentz vector in uproot4. But I found that methods in "uproot_methods" module are now worked with Awkward High level array. Error message # --------------------------------------------> Traceback (most recent call last): File…
jiwoong
  • 19
  • 1
0
votes
1 answer

Cartesian (cross) products and np.unique()

Depending on your few on my approach this is either a question about using np.unique() on awkward1 arrays or a call for a better approach: Let a and b be two awkward1 arrays of the same outer length (number of events) but different inner lengths.…
Superharz
  • 1
  • 1
0
votes
2 answers

while loop equivalent function/snippet in awkward array

I have a function which I would like to convert so that i can use with awkward array 1. Function following which used to work for float but not for awkward arrays for the known reasons. def Phi_mpi_pi(x): kPI=(3.14159265) kTWOPI = 2 * kPI …
Raman Khurana
  • 125
  • 1
  • 7
0
votes
2 answers

Convert list of tuples in list of lists ( NP array )

i have a array response from a api and i got this poly: poly = [(0,525),(961,525),(961,1003),(0,1003)] i need to multiply each item for 0.35, them my code was it: poly = ak.Array(poly) * (35/100) i got a object…
Jasar Orion
  • 626
  • 7
  • 26
0
votes
1 answer

Awkward-array test for elements of one JaggedArray in another

I need to perform a calculation on a JaggedArray, but only if the elements in the JaggedArray are in contained in another JaggedArray. I'd like to receive back a mask with True if the element in is another JaggedArray, or False otherwise (ie. should…
0
votes
0 answers

Python AwkwardArray: How to define a cyclic array?

I have been searching for a way to create a: Bounded Cyclic Contiguous numpyable API'ed array. I came across AwkwardArray, but was not able to make sense of the doc, which is very verbose, but unindexed for my term. I would like to define an array…
Gulzar
  • 23,452
  • 27
  • 113
  • 201
1 2 3 4
5