-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: beam-refactor
Are you sure you want to change the base?
Refactor index types #405
Conversation
There was a problem hiding this 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}") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
This is an internal refactor of the core
Index
datatype. Like xarray-beamKey
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:
Index
to a standalonetypes
moduleIndex
to use a key value pair ofDimension
andPosition
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.