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: preserve dimensions for keepdims=True, axis=None reductions #2177

Merged
merged 6 commits into from
Jan 31, 2023

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Jan 30, 2023

Fixes #2159 by adding a new keepdims to the renamed ak._do.remove_structure function. This just moves the list boundaries to the start and end elements of each list, so that the final result is a nested series of length-1 lists (besides the innermost dimension of length N).

@agoose77 agoose77 requested a review from jpivarski January 30, 2023 22:41
Comment on lines +802 to +808
if not check_regular and (
left.is_list and right.is_regular or left.is_regular and right.is_list
):
left = left.to_ListOffsetArray64()
right = right.to_ListOffsetArray64()
else:
return False
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't use this here, but I wrote it, and then removed the usage. I think it's good to keep for future tests.

@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Merging #2177 (b3612f6) into main (9c94665) will increase coverage by 0.05%.
The diff coverage is 82.71%.

Additional details and impacted files
Impacted Files Coverage Δ
src/awkward/behaviors/string.py 76.97% <0.00%> (ø)
src/awkward/contents/__init__.py 100.00% <ø> (ø)
src/awkward/index.py 89.80% <0.00%> (ø)
src/awkward/operations/ak_cartesian.py 90.62% <ø> (ø)
src/awkward/operations/ak_to_dataframe.py 92.50% <0.00%> (ø)
src/awkward/operations/ak_unflatten.py 95.52% <ø> (ø)
src/awkward/contents/bitmaskedarray.py 68.22% <50.00%> (ø)
src/awkward/contents/bytemaskedarray.py 88.75% <50.00%> (ø)
src/awkward/contents/indexedarray.py 78.41% <50.00%> (+0.71%) ⬆️
src/awkward/contents/unmaskedarray.py 73.44% <50.00%> (-0.83%) ⬇️
... and 36 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.

This is mostly just a renaming, but it implements keep_dims for lists. 👍

@agoose77 agoose77 changed the title refactor: rename _completely_flatten to _remove_structure fix: preserve dimensions for keepdims=True, axis=None reductions Jan 30, 2023
@agoose77 agoose77 temporarily deployed to docs-preview January 30, 2023 22:54 — with GitHub Actions Inactive
@agoose77 agoose77 enabled auto-merge (squash) January 30, 2023 23:01
@agoose77 agoose77 temporarily deployed to docs-preview January 30, 2023 23:08 — with GitHub Actions Inactive
@agoose77 agoose77 temporarily deployed to docs-preview January 31, 2023 00:01 — with GitHub Actions Inactive
@agoose77 agoose77 temporarily deployed to docs-preview January 31, 2023 08:48 — with GitHub Actions Inactive
@agoose77 agoose77 merged commit a91d96b into main Jan 31, 2023
@agoose77 agoose77 deleted the agoose77/fix-keepdims-axis-none branch January 31, 2023 08:57
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.

Reducers with axis=None, keepdims=True differ from NumPy result
2 participants