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

Add drop=True argument to isel, sel and squeeze #1153

Merged
merged 4 commits into from
Dec 16, 2016
Merged

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Dec 5, 2016

Fixes #242

This is useful for getting rid of extraneous scalar variables that arise from
indexing, and in particular will resolve an issue for optional indexes:
#1017 (comment)

Fixes GH242

This is useful for getting rid of extraneous scalar variables that arise from
indexing, and in particular will resolve an issue for optional indexes:
pydata#1017 (comment)
Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

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

This looks quite nice. Just expand the tests for squeeze a bit and we're good to go.

expected = Dataset({'foo': 1}, {'x': 0})
selected = data.squeeze(drop=False)
self.assertDatasetIdentical(expected, selected)

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a few more tests to this section:

  • squeeze empty array
  • squeeze 2d array with a single element

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@shoyer
Copy link
Member Author

shoyer commented Dec 9, 2016

Going to merge this shortly unless anyone has objections

@pwolfram
Copy link
Contributor

pwolfram commented Dec 9, 2016

@shoyer, I think this is really great and appreciate you doing this awesome work. I obviously have a vested interest in the drop=True capability because we have found great use for it via where. My vote is go for it!

@shoyer
Copy link
Member Author

shoyer commented Dec 9, 2016

I obviously have a vested interest in the drop=True capability because we have found great use for it via where.

Well, to be clear drop=True works pretty differently on these methods than in where, so this might be confusing.

For isel, sel and squeeze, it drops scalar coordinates variables that would arise from indexing, whereas for where it drops some coordinate values. That said, the drop method already handles both cases.

@shoyer shoyer merged commit 89a6732 into pydata:master Dec 16, 2016
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.

Add a "drop" option to squeeze
3 participants