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

fix: carry parameters through broadcasting #1679

Merged
merged 19 commits into from
Sep 7, 2022

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Sep 7, 2022

Fixes #1672

@jpivarski and I discussed the ramifications of this on Zoom. We have always been setting the parameters to None in

This PR introduces a new broadcast_parameters_rule enumeration that selects from the following rules:

  • "intersect"
    Take the intersection of the broadcasted input parameters.
  • "all_or_nothing"
    Take the first content's parameters if they are equal to all of the other content's parameters, otherwise None.
  • "one_to_one"
    Assert that the broadcast output matches the broadcast inputs, and if so, take the corresponding parameters (by position).
  • "none"
    Always set parameters to None (previous behaviour)

This introduces new parameter broadcasting modes:
- `INTERSECT`
- `ONE_TO_ONE`
- `ALL_OR_NOTHING`
- `NONE`

The previous default was `None`.

The meaning of these broadcasting modes, set using the `"broadcast_parameters_rule"` option key, can be found in the source code.
@codecov
Copy link

codecov bot commented Sep 7, 2022

Codecov Report

Merging #1679 (cbf4c35) into main (e692946) will increase coverage by 0.35%.
The diff coverage is 88.58%.

Additional details and impacted files
Impacted Files Coverage Δ
src/awkward/_v2/_connect/jax/__init__.py 90.47% <ø> (+1.58%) ⬆️
src/awkward/_v2/operations/ak_broadcast_arrays.py 100.00% <ø> (+4.34%) ⬆️
src/awkward/_v2/operations/ak_transform.py 65.51% <ø> (+56.89%) ⬆️
src/awkward/_v2/types/uniontype.py 84.61% <ø> (ø)
src/awkward/_v2/highlevel.py 71.68% <33.33%> (-0.16%) ⬇️
src/awkward/_v2/behaviors/categorical.py 73.13% <60.00%> (-8.94%) ⬇️
src/awkward/_v2/forms/form.py 82.95% <68.51%> (-7.80%) ⬇️
src/awkward/_v2/forms/emptyform.py 76.47% <75.00%> (+1.08%) ⬆️
src/awkward/_v2/forms/unionform.py 73.75% <75.00%> (+0.57%) ⬆️
src/awkward/_v2/_broadcasting.py 93.39% <88.46%> (-1.18%) ⬇️
... and 45 more

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.

We discussed this on Zoom; I think this is a great solution!

The Sentinel will be moving to _util (:checkmark:).

I think the strings should be lower-case, at least when they are arguments to ak.transform (not done yet). It would be fine for the Enums to be upper-case (they're constants) while the strings that represent them are lower-case. It would also be fine to use just strings and not Enums. (This would be the first use of Enum.)

@agoose77 agoose77 enabled auto-merge (squash) September 7, 2022 16:11
@agoose77 agoose77 enabled auto-merge (squash) September 7, 2022 17:21
@agoose77
Copy link
Collaborator Author

agoose77 commented Sep 7, 2022

OK, I think this is ready to go. I want to, in a future PR, increase the coverage of these test. Right now, we have enough to consider merging this PR.

@agoose77 agoose77 enabled auto-merge (squash) September 7, 2022 17:25
@agoose77 agoose77 merged commit 31f3afb into main Sep 7, 2022
@agoose77 agoose77 deleted the agoose77/fix-broadcasting-parameters branch September 7, 2022 18:00
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.

ak.transform converts string to list of bytes if multiple arrays are passed
2 participants