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.min
changes index of empty nested lists
#982
Comments
Hi @fleble, thanks for filing a report! From reading the documentation, I would expect that for the unmasked case, you should see the same result as the masked case. Semantically, the empty lists are still If this is a bug, then it might be an issue with the kernel for the output offset calculations e.g. https://github.com/scikit-hep/awkward-1.0/blob/a70a535a818d54c6dcdb60711dff09a283441541/src/cpu-kernels/awkward_ListOffsetArray_reduce_nonlocal_outstartsstops_64.cpp but I don't know enough about this layer to be able to confidently say anything. @ianna or @jpivarski will know whether this is intended behaviour. |
@fleble - thanks for reporting this! I'd expect the latter output, because when
I think, it should be:
|
I think you're right. I think it should not be moving that empty list. Here's a similar example in NumPy: >>> np_array = np.array([
... [[1, 2, 3], [9, 9, 9], [4, 3, 2]],
... [[4, 5, 6], [9, 9, 9], [2, 3, 4]]
... ])
>>> np.min(np_array, axis=0)
array([[1, 2, 3],
[9, 9, 9],
[2, 3, 2]])
>>> np_array = np.array([
... [[1, 2, 3], [0, 0, 0], [4, 3, 2]],
... [[4, 5, 6], [0, 0, 0], [2, 3, 4]]
... ])
>>> np.min(np_array, axis=0)
array([[1, 2, 3],
[0, 0, 0],
[2, 3, 2]]) And here's an example where the list is not empty, but has one element: >>> ak_array = ak.Array([
... [[1, 2, 3], [9], [4, 3, 2]],
... [[4, 5, 6], [9], [2, 3, 4]]
... ])
>>> ak.min(ak_array, axis=0)
<Array [[1, 2, 3], [9], [2, 3, 2]] type='3 * var * ?int64'> Actually, that last one clinches it: the length-0 list should not be moving, as a length-1 list does not. |
Thank you for the fast replies! Glad to help by reporting this bug and thank you for the development of this package! |
Yes, this issue will be linked to a PR addressing it. Thanks again! |
This was super-tricky and got at the heart of how nonlocal reducers (i.e. Should be fixed now, though. |
I wonder if the following is a bug or a feature:
The empty nested list is now in last index.
This works if the array is masked though:
Is this a bug in
ak.min
or should one always mask the ak array for such kind of operations?The text was updated successfully, but these errors were encountered: