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

Chunk-aligned indexing #183

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Chunk-aligned indexing #183

wants to merge 3 commits into from

Conversation

TomNicholas
Copy link
Member

Allows you to subset ManifestArray objects, as long as your indexer slice aligns with chunk boundaries.

@TomNicholas TomNicholas added the enhancement New feature or request label Jul 11, 2024
Comment on lines +344 to +347
marr = create_manifestarray(shape=(4,), chunks=(2,))
marr[0:2]
marr[2:4]
marr[0:4]
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to come back and improve these placeholder tests

Comment on lines +329 to +332
if chunk_length == 1:
# alot of indexing is possible only in this case, because this is basically just a normal array along that axis
chunk_slice = array_slice
return chunk_slice
Copy link
Member Author

Choose a reason for hiding this comment

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

Kind of interesting to realise this. You can even do things like slice(None, None, -1) to reverse the array in this case.

Comment on lines +318 to +324
def _array_slice_to_chunk_slice(
array_slice: slice,
arr_length: int,
chunk_length: int,
) -> slice:
"""
Translate a slice into an array into a corresponding slice into the underlying chunk grid.
Copy link
Member Author

Choose a reason for hiding this comment

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

@d-v-b this is a first step in the direction of #71


indexer = _possibly_expand_trailing_ellipsis(key, self.ndim)
# _validate_indexer(indexer)
Copy link
Member Author

Choose a reason for hiding this comment

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

(probably don't need this as separate function)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support indexing by slicing along chunk boundaries?
1 participant