Skip to content

Clarify rules for copies vs views when indexing #512

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

Merged
merged 2 commits into from
Aug 20, 2015

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Aug 4, 2015

This mostly reorganizes/updates the indexing documentation.

It also catches an edge case where a slice based indexer could be converted silently into array indexer. This is a strange edge case involving unsorted or duplicate indexes that arguably pandas shouldn't allow anyways.

@shoyer
Copy link
Member Author

shoyer commented Aug 5, 2015

@jhamman any thoughts?


Like pandas, whether array indexing returns a view or a copy of the underlying
data depends entirely on numpy:
The label based selection methods :py:meth:`~xray.Dataset.sel`,
Copy link
Member

Choose a reason for hiding this comment

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

also sel_points

* Label-based indexing with arrays returns a copy.
* Label-based indexing with scalars returns a view or a copy, depending
upon if the corresponding positional indexer can be represented as an
integer or a slice object.
Copy link
Member

Choose a reason for hiding this comment

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

for the last point, an example showing both behaviors may be helpful.

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately, the distinction here is pretty complex and I'm not even sure I understand it fully...

@jhamman
Copy link
Member

jhamman commented Aug 5, 2015

I made a few comments. I think you'll have to sort out the merge conflicts coming from #507.

@shoyer shoyer force-pushed the slice-indexing-never-copies branch from bb51a8e to 5814a12 Compare August 19, 2015 18:24
@shoyer
Copy link
Member Author

shoyer commented Aug 19, 2015

Revised and rebased.

@jhamman
Copy link
Member

jhamman commented Aug 20, 2015

I'm not able to build the docs from where I am but from what I can tell, this looks good.

shoyer added a commit that referenced this pull request Aug 20, 2015
Clarify rules for copies vs views when indexing
@shoyer shoyer merged commit 3865ff2 into pydata:master Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants