-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Clean up backend indexing some more #10376
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
base: main
Are you sure you want to change the base?
Conversation
for k, v in self._variables.items(): | ||
v = v.copy(deep=True) | ||
res[k] = v | ||
v._data = indexing.LazilyIndexedArray(v._data) |
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.
Harmonizes this test backend with all the other backends
@@ -190,7 +190,7 @@ def ds(self): | |||
def open_store_variable(self, name, var): | |||
return Variable( | |||
var.dimensions, | |||
ScipyArrayWrapper(name, self), | |||
indexing.LazilyIndexedArray(ScipyArrayWrapper(name, self)), |
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.
harmonized with the other backends
for more information, see https://pre-commit.ci
@@ -717,7 +717,7 @@ def from_variables( | |||
|
|||
# preserve wrapped pd.Index (if any) | |||
# accessing `.data` can load data from disk, so we only access if needed | |||
data = var._data.array if hasattr(var._data, "array") else var.data | |||
data = var._data if isinstance(var._data, PandasIndexingAdapter) else var.data |
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.
@benbovy is this right?
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.
It looks right to me. data = var._data.array if isinstance(...
would also work but the pandas Index object should be further extracted from the indexing adapter class via safe_cast_to_index
.
array = self.array[self.key] | ||
|
||
# self.array[self.key] is now a numpy array when |
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.
This is a nice win and means we have increased internal consistency.
xref #6874 (comment) and #6874 (comment)
Harmonizes some internal code paths to make the async work less painful (#10327).
I'll add comments for the remaining changes