Skip to content

Fix variable copy with multi-index #881

Merged
shoyer merged 2 commits into
pydata:masterfrom
benbovy:multi-index_fix-copy
Jun 16, 2016
Merged

Fix variable copy with multi-index #881
shoyer merged 2 commits into
pydata:masterfrom
benbovy:multi-index_fix-copy

Conversation

@benbovy

@benbovy benbovy commented Jun 13, 2016

Copy link
Copy Markdown
Member

Fixes #769.

Comment thread xarray/core/variable.py Outdated
if isinstance(self._data, PandasIndexAdapter):
# there is no need to copy the index values here even if deep=True
# since pandas.Index objects are immutable
data = PandasIndexAdapter(self) if deep else self._data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need these two different code paths? Why not always return self._data in this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I saw this in Coordinate.copy() so I thought there might have some wrapper data to copy in PandasIndexAdapter but I admit I didn't checked it.

Indeed, now that I see why we have this in Coordinate.copy() I don't see any reason to have these two different code paths here.

@shoyer shoyer merged commit 065ea6a into pydata:master Jun 16, 2016
@shoyer

shoyer commented Jun 16, 2016

Copy link
Copy Markdown
Member

Thanks!

@benbovy benbovy mentioned this pull request Jul 19, 2016
@benbovy benbovy deleted the multi-index_fix-copy branch August 1, 2016 14:17
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