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

feat: prevent reducers like ak.sum on records (v2) #1607

Merged
merged 8 commits into from
Aug 25, 2022

Conversation

ioanaif
Copy link
Collaborator

@ioanaif ioanaif commented Aug 19, 2022

This PR addresses issue #1375:

If we have records whose fields represent non-Cartesian data, they should not be naively added (or otherwise "reduced")

>>> ak.sum(ak.Array([[{"rho": 1.1, "phi": -0.1}, {"rho": 2.2, "phi": 0.1}]]), axis=1)
<Array [{rho: 3.3, phi: 0}] type='1 * {"rho": float64, "phi": float64}'>

In V2, this will now throw a TypeError
Error details: no ak.sum overloads for custom types: rho, phi

@ioanaif ioanaif linked an issue Aug 19, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #1607 (7d69c81) into main (9e17f29) will increase coverage by 0.18%.
The diff coverage is 65.07%.

Impacted Files Coverage Δ
src/awkward/_v2/_connect/cuda/__init__.py 0.00% <0.00%> (ø)
src/awkward/_v2/_connect/numexpr.py 88.40% <0.00%> (ø)
src/awkward/_v2/_connect/pyarrow.py 88.46% <0.00%> (ø)
...awkward/_v2/_connect/rdataframe/from_rdataframe.py 0.00% <0.00%> (ø)
src/awkward/_v2/_lookup.py 98.68% <ø> (+1.17%) ⬆️
src/awkward/_v2/numba.py 93.47% <0.00%> (ø)
src/awkward/_v2/operations/ak_from_avro_file.py 66.66% <0.00%> (ø)
src/awkward/_v2/operations/ak_local_index.py 100.00% <ø> (ø)
src/awkward/_v2/operations/ak_max.py 87.09% <ø> (ø)
src/awkward/_v2/operations/ak_min.py 87.09% <ø> (ø)
... and 48 more

@ioanaif ioanaif requested a review from jpivarski August 24, 2022 16:46
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I just have one requested change. You've added a behavior-lookup, and there's a common form for those in helper functions in _util. See below.

With that behavior-lookup refactored out to _util.py, this will be ready. Re-request me to review it and I'll do a quick check, then merge.

Thanks!

src/awkward/_v2/contents/recordarray.py Outdated Show resolved Hide resolved
@ioanaif ioanaif changed the title policy: prevent reducers like ak.sum on records (v2) fix: prevent reducers like ak.sum on records (v2) Aug 25, 2022
@ioanaif ioanaif requested a review from jpivarski August 25, 2022 13:11
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in meeting; this is ready to go!

@jpivarski jpivarski enabled auto-merge (squash) August 25, 2022 13:34
@ioanaif ioanaif changed the title fix: prevent reducers like ak.sum on records (v2) feat: prevent reducers like ak.sum on records (v2) Aug 25, 2022
@jpivarski jpivarski merged commit 91fddcc into main Aug 25, 2022
@jpivarski jpivarski deleted the ioanaif/fix-reducers-records-1375 branch August 25, 2022 14:53
Saransh-cpp pushed a commit to Saransh-cpp/awkward that referenced this pull request Aug 29, 2022
* policy: Prevent reducers like ak.sum on records (v2)

* Pass behavior on the rest of the reducers

* Made a util function for checking if a reducer function is overloaded for records

* Switch using .split with .name

* Add 'highlevel_function()
utility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent reducers like ak.sum on records (v1 and v2)
2 participants