-
Allow
This would make it possible to pass already flat arrays (it would just return the array as is was) and you wouldn't have to worry about the depth of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I couldn't exactly reproduce this, even going back to 0.4.5. If you pass (The C++ code was written under the assumption that The only way to express "flatten if not already flat" without exceptions is >>> ak.flatten(ak.Array([[1, 2, 3], [], [4, 5]]), axis=None)
<Array [1, 2, 3, 4, 5] type='5 * int64'>
>>> ak.flatten(ak.Array([1, 2, 3, 4, 5]), axis=None) Be sure it's what you want, though. Unlike a single-axis flatten, it flattens all levels of depth: >>> ak.flatten(ak.Array([[[1, 2], [], [3]], [], [[4, 5]]]), axis=None)
<Array [1, 2, 3, 4, 5] type='5 * int64'> and even flattens records: >>> ak.flatten(ak.Array([{"x": 1.1, "y": [1]}, {"x": 2.2, "y": [1, 2]}]), axis=None)
<Array [1.1, 2.2, 1, 1, 2] type='5 * float64'> |
Beta Was this translation helpful? Give feedback.
-
Thank you for the explanation. I have to admit that I never actually tried |
Beta Was this translation helpful? Give feedback.
I couldn't exactly reproduce this, even going back to 0.4.5. If you pass
axis=0
toak.flatten
, the case is handled in Python code and you don't get this error message that comes from C++. Tinkering with it, I did find an unhandled corner-case: if you pass the negative axis that is equivalent toaxis=0
(such asaxis=-2
for a singly jagged array oraxis=-1
for a flat array), it missed the check foraxis == 0
and went into C++. As far as I can see, that's the only way to encounter this error message.(The C++ code was written under the assumption that
axis == 0
would never be allowed, but it made sense to add that case, though its behavior is entirely different from any otheraxis
value. Since