Replies: 1 comment
-
There isn't an
So that would be nice, and it could be a feature request for Awkward Array (probably not addressed in the next month or so, to be honest). If you main concern is performance, note that your interpretation, If your concern is convenience, you might want to consider a list comprehension. Wait a minute—(facepalm)—there's a nice implementation for vectorized >>> strings = ak.Array([
... ["ci_EMCAL-one", "ci_EMCAL-two", "something else"],
... [],
... ["yet another thing", "ci_EMCAL-three"]])
>>> print(strings[:, :, :len("ci_EMCAL")])
[['ci_EMCAL', 'ci_EMCAL', 'somethin'], [], ['yet anot', 'ci_EMCAL']]
>>> print(strings[:, :, :len("ci_EMCAL")] == "ci_EMCAL")
[[True, True, False], [], [False, True]] There you go. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Actually, this relates to this question #229 and the same data as there - hits and tracks connected by ids
We have a data field which is a vector of std::strings.
gives
In reality each hit has a string with the volume name. Not very effective in terms of performance, but beyond this discussion. These strings looks like "ci_EMCAL_section1_tower22" and the naming is organized so that if one wants to get all hits in central-ion-cap EMCAL, he just need a filter like
I'm sure I could somehow flatten the data and those string would appear correctly in flattened arrays, where I could use
numpy.char.startswith
to select all hits from ci_EMCALBut I'm wonder if one can do it inside iterate method without data flattening. Because as in #229 I would like to use this to get certain tracks:
Beta Was this translation helpful? Give feedback.
All reactions