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

Refactor index types #405

Draft
wants to merge 14 commits into
base: beam-refactor
Choose a base branch
from

Conversation

rabernat
Copy link
Contributor

@rabernat rabernat commented Aug 29, 2022

This is an internal refactor of the core Index datatype. Like xarray-beam Key we use something that looks like a dictionary to keep track of where a fragment lies within a dataset.

This PR does a few things:

  • Moves Index to a standalone types module
  • Refactors Index to use a key value pair of Dimension and Position
  • Tries to eliminate redundancy in Position, moving closer to xarray-beam's "offests" concept.

We may be able to eventually just use the same type of index as xarray-beam. In the meantime, this simplifies things and moves us in that direction.

My main complaint is that this feels a very java-like.

cc @shoyer and @alxmrs if you want to take a look.

Copy link
Contributor

@alxmrs alxmrs left a comment

Choose a reason for hiding this comment

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

Two small nits. Looks great!

]
if len(dims) != 1:
raise KeyError(r"Could not valid combine_dim for indexer {idx_key}")
raise KeyError(f"Could not valid combine_dim for dimension {dimension}")
Copy link
Contributor

Choose a reason for hiding this comment

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

My personal preference is {dimension!r}.

assert concat_dim_val.stop == concat_dim_val.start + dimsize
region_slice.append(slice(concat_dim_val.start, concat_dim_val.stop))
position = index[concat_dimension]
assert position.indexed
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be useful to have an assert message, maybe with some message to help end-users debug.

@rabernat rabernat mentioned this pull request Oct 6, 2022
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.

2 participants