Skip to content

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

Merged
shoyer merged 4 commits into
pydata:masterfrom
shoyer:drop
Dec 16, 2016
Merged

Add drop=True argument to isel, sel and squeeze#1153
shoyer merged 4 commits into
pydata:masterfrom
shoyer:drop

Conversation

@shoyer

@shoyer shoyer commented Dec 5, 2016

Copy link
Copy Markdown
Member

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)

@jhamman jhamman left a comment

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.

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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

@shoyer

shoyer commented Dec 9, 2016

Copy link
Copy Markdown
Member Author

Going to merge this shortly unless anyone has objections

@pwolfram

pwolfram commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

@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

shoyer commented Dec 9, 2016

Copy link
Copy Markdown
Member Author

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