Skip to content

Auto rechunk to enable blockwise reduction #380

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dcherian
Copy link
Collaborator

@dcherian dcherian commented Aug 2, 2024

Done when

  1. method is None
  2. Grouping and reducing by a 1D array
  3. by is sorted.
  • test for descending too
  • support descending by too

We gate this on fractional change in number of chunks and change in size of largest chunk.

Closes #359

Sorry, something went wrong.

@dcherian dcherian force-pushed the auto-blockwise-rechunk branch 5 times, most recently from bcae992 to 0c0b0e5 Compare August 2, 2024 22:00
@dcherian dcherian force-pushed the auto-blockwise-rechunk branch 4 times, most recently from f0af7ee to 20e6ed8 Compare June 17, 2025 05:08
Done when
1. `method` is None
2. Grouping and reducing by a 1D array

We gate this on fractional change in number of chunks and change in size
of largest chunk.

Closes #359
@dcherian dcherian force-pushed the auto-blockwise-rechunk branch from 20e6ed8 to d9a7ab5 Compare June 17, 2025 05:13
new_input_chunks = chunks

# FIXME: this should be unnecessary?
labels = factorize_((labels,), axes=())[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: get rid of this line

@@ -119,6 +119,15 @@
# _simple_combine.
DUMMY_AXIS = -2

# Thresholds below which we will automatically rechunk to blockwise if it makes sense
# 1. Fractional change in number of chunks after rechunking
BLOCKWISE_RECHUNK_NUM_CHUNKS_THRESHOLD = 0.25
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: these should probably be in some kind of "options" context manager

if ascending:
return bool((arr[:-1] <= arr[1:]).all())
else:
return bool((arr[:-1] >= arr[1:]).all())
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should add a test for descending

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.

Consider preferred_method="blockwise" if by is sorted
1 participant