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

ufuncs on records should not be allowed unless they are explicitly overridden. #1439

Closed
jpivarski opened this issue Apr 22, 2022 · 0 comments
Assignees
Labels
bug The problem described is something that must be fixed

Comments

@jpivarski
Copy link
Member

Unless explicitly overridden, ufuncs are not supposed to work on records. In v1:

>>> array = ak.Array([{"x": 1.0, "y": 1.1}, {"x": 2.0, "y": 2.2}])
>>> np.absolute(array)
Traceback (most recent call last):
...
  File "/home/jpivarski/irishep/awkward-1.0/awkward/_util.py", line 1058, in apply
    raise ValueError(
ValueError: cannot broadcast records in this type of operation

(https://github.com/scikit-hep/awkward-1.0/blob/1.9.0rc2/src/awkward/_util.py#L1060)

(that's good), but in v2:

>>> array = ak._v2.Array([{"x": 1.0, "y": 1.1}, {"x": 2.0, "y": 2.2}])
>>> np.absolute(array)
<Array [{x: 1, y: 1.1}, {x: 2, ...}] type='2 * {x: float64, y: float64}'>

(that's bad).

In v1, this was issue #457 and PR #510, which added:

https://github.com/scikit-hep/awkward-1.0/blob/779819e0405cd481dbae0976fc311f2f1d91d9b5/src/awkward/_util.py#L1057-L1061

It looks like the check was copied into v2:

https://github.com/scikit-hep/awkward-1.0/blob/779819e0405cd481dbae0976fc311f2f1d91d9b5/src/awkward/_v2/_broadcasting.py#L653-L656

but it's not being triggered in the above example for some reason.

Originally posted by @jpivarski in #1437 (comment)

@jpivarski jpivarski added the bug The problem described is something that must be fixed label Apr 22, 2022
@ioanaif ioanaif self-assigned this Jul 7, 2022
@ioanaif ioanaif closed this as completed Jul 28, 2022
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

No branches or pull requests

2 participants