Skip to content
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.cartesian(..., nested=True) results in behaviour expected from nested=False #2928

Closed
danielhundhausen opened this issue Jan 10, 2024 · 1 comment · Fixed by #2929
Closed
Assignees
Labels
bug The problem described is something that must be fixed

Comments

@danielhundhausen
Copy link

Version of Awkward Array

2.5.1

Description and code to reproduce

In awkward 2 the behaviour from ak.cartesian is unexpected and deviant from behaviour in v1.

>>> one = ak.zip({"pt": [[1, 2], [1]], "eta": [[1.1, 2.1], [1]]})
>>> two = ak.zip({"pt": [[2.1], [2.21, 2.22]], "eta": [[2.11], [2.221, 2.222]]})
>>> ak.cartesian({"foo": one, "bar": two}, nested=False)["foo"].show()
[[{pt: 1, eta: 1.1}, {pt: 2, eta: 2.1}],
 [{pt: 1, eta: 1}, {pt: 1, eta: 1}]]
ak.cartesian({"foo": one, "bar": two}, nested=True)["foo"].show()
[[{pt: 1, eta: 1.1}, {pt: 2, eta: 2.1}],
 [{pt: 1, eta: 1}, {pt: 1, eta: 1}]]

In v1 (1.9.0) the behaviour was:

>>> for x in ak.cartesian({"foo": one, "bar": two}, nested=True)["foo"]:
>>>     print(x)
[[{pt: 1, eta: 1.1}], [{pt: 2, eta: 2.1}]]
[[{pt: 1, eta: 1}, {pt: 1, eta: 1}]]
>>> for x in ak.cartesian({"foo": one, "bar": two}, nested=False)["foo"]:
>>>     print(x)
[{pt: 1, eta: 1.1}, {pt: 2, eta: 2.1}]
[{pt: 1, eta: 1}, {pt: 1, eta: 1}]

Am I misinterpreting what ak.cartesian(..., nested=True) should do or is this a bug?

Thanks for considering this comment!

@danielhundhausen danielhundhausen added the bug (unverified) The problem described would be a bug, but needs to be triaged label Jan 10, 2024
@agoose77
Copy link
Collaborator

This behaviour has changed in awkward 2.x, but not intentionally; it does behave as described in 2.1.0. This code was recently refactored, I'll take a look and see what was dropped!

@agoose77 agoose77 self-assigned this Jan 10, 2024
@agoose77 agoose77 added bug The problem described is something that must be fixed and removed bug (unverified) The problem described would be a bug, but needs to be triaged labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The problem described is something that must be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants