awkward icon indicating copy to clipboard operation
awkward copied to clipboard

Why filtering on regular array works differently?

Open ianna opened this issue 3 months ago • 0 comments

Discussed in https://github.com/scikit-hep/awkward/discussions/3668

Originally posted by wiso October 6, 2025 I read some data from uproot and the resulting array is represented as a regular array

values.layout is

<RegularArray size='1024' len='1104'>
    <content><NumpyArray dtype='uint16' len='1130496'>[  0   0   0 ... 100  98  98]</NumpyArray></content>
</RegularArray>

Values are

[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ..., 97, 85, 93, 100, 76, 108, 85, 94, 109, 87]]
--------------------------------------------------------------------------------
backend: cpu
nbytes: 2.3 MB
type: 3 * 1024 * uint16

if I apply a filter

values[values != 0] I get a 1D array

which is not what I expect.

I solved with

values = ak.from_regular(values)

but this seems awkward

ianna avatar Oct 06 '25 08:10 ianna