-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ak.unflatten
does not always respect zero counts
#905
Comments
I think the cause here is the various There is another case with array = ak.Array([0, 2, 2, 2, 2, 2])
lengths = ak.Array([1, 0, 4, 0, 0, 0])
ak.unflatten(array, lengths) fails |
"Getting zeros right" was an active effort at one point—the fact that the counts can contain zeros was not ignored. The this that's supposed to do this is called There are some ambiguities in where to put the zeros when partitioning is involved: the same zero-length list could just as well go at the end of one partition or the beginning of another. The current choice was made to make it easier to not lose any zero-length lists at the end of the array (zeros at the end of |
Ah, I can now see that I didn't notice that the problem of arranging zero-length lists is degenerate in the nested axis case; as you say, without a size constraint the zero-length lists can be placed in either partition. However, in this case, the meaning of
or
or any intermediate configuration thereof, but there should still (in my opinion) be three lists somewhere? |
Oh yeah, it's not just an ambiguity between partitions, but also between nested lists if you're unflattering inside of existing lists, like with |
@jpivarski it looks that way (for |
Still, for my use case, perhaps I'll need to roll a custom version |
Though old, this was still a bug and had to be fixed! (I'm putting the same corrections into the commented out code that's waiting to be ported to v2, so that it doesn't regress. Also, there's a test and all tests will be ported, too. |
I expect the function to produce the layout as shown on the RHS,
[[[], [], []], [[0], [], [2, 2, 2, 2, 2]]]
.I would like to support zeros like this, because I want the output to be a regular array. I am effectively using a modified
run_lengths
to count runs of a predefined list of keys.I may be able to look at this today, I'll self-assign if so.
The text was updated successfully, but these errors were encountered: