You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
In all cases, AwkwardArray.regular should turn the awkward array into a plain ol' Numpy array, if possible. JaggedArray already has such a method, but it would also be useful in UnionArray when all contents are Numpy.
This is related to #84, the request for an awkward.where(flatbool, a, b) method that takes a[i] from a if flatbool[i] and b[i] from b otherwise. Such a function would always return a UnionArray except for some specialized cases if we choose to single them out and implement them. The simple implementation of where would be:
defwhere(condition, x, y):
assertlen(condition) ==len(x) ==len(y)
returnUnionArray(condition.astype(UnionArray.TAGTYPE), # bools -> tagsnumpy.arange(len(x)), # trivial indexes
[y, x]) # false -> 0, which is y
which basically just delays the application of the condition. Delayed evaluation is necessary because x and y might be too complex to mix, even if they are the same type. (That's why specialized cases may be handled differently, but probably shouldn't for regularity.) This isn't a problem for analysts: you can do all the
a["pt"][:, 0]
stuff on a UnionArray just like any jagged table or whatever.
But then, to make this useful, you need a way of eventually evaluating the where, once you've broken down the structure to something that can be pure Numpy. UnionArray.regular can be
In all cases,
AwkwardArray.regular
should turn the awkward array into a plain ol' Numpy array, if possible.JaggedArray
already has such a method, but it would also be useful inUnionArray
when allcontents
are Numpy.This is related to #84, the request for an
awkward.where(flatbool, a, b)
method that takesa[i]
froma
ifflatbool[i]
andb[i]
fromb
otherwise. Such a function would always return aUnionArray
except for some specialized cases if we choose to single them out and implement them. The simple implementation ofwhere
would be:which basically just delays the application of the condition. Delayed evaluation is necessary because
x
andy
might be too complex to mix, even if they are the same type. (That's why specialized cases may be handled differently, but probably shouldn't for regularity.) This isn't a problem for analysts: you can do all thestuff on a
UnionArray
just like any jagged table or whatever.But then, to make this useful, you need a way of eventually evaluating the
where
, once you've broken down the structure to something that can be pure Numpy.UnionArray.regular
can bewhich is a more-than-two version of
numpy.where
.The text was updated successfully, but these errors were encountered: