-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
adding stack_all #3115
adding stack_all #3115
Conversation
* switching out examples to use nbsphinx * added jupyter_client to doc env * added ipykernel to doc env
* switching out examples to use nbsphinx * added jupyter_client to doc env * moved gallery to notebook
Codecov Report
@@ Coverage Diff @@
## master #3115 +/- ##
==========================================
- Coverage 95.99% 95.97% -0.02%
==========================================
Files 63 63
Lines 12796 12808 +12
==========================================
+ Hits 12283 12292 +9
- Misses 513 516 +3 |
Hello @vrx-! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-07-17 01:40:06 UTC |
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.
Thanks @vrx- . I've added some comments.
EDIT: You should add a line under "New functions" in whats-new.rst
and give yourself credit.
|
||
Parameters | ||
---------- | ||
name : Name of the new dimension. Optional. |
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.
Same suggestion as above.
* x (x) |S1 'a' 'b' | ||
* y (y) int64 0 1 2 | ||
>>> stacked = arr.stack_all() | ||
>>> stacked.indexes['z'] |
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.
Same here.
DataArray.stack | ||
DataArray.unstack | ||
""" | ||
result = 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.
Do we need self.copy()
?
@@ -1341,6 +1341,13 @@ def test_stack(self): | |||
expected = Variable(('X', 'Y'), v.data, v.attrs) | |||
assert_identical(actual, expected) | |||
|
|||
def test_stack_all(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.
Let's add similar tests to test_dataarray.py
and test_dataset.py
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.
@@ -1280,6 +1280,30 @@ def stack(self, dimensions=None, **dimensions_kwargs): | |||
result = result._stack_once(dims, new_dim) | |||
return result | |||
|
|||
def stack_all(self, name='stacked'): |
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.
I'm not sure we need the xarray.Variable
method.
Variable
is a lower-level API, mostly for internal use inside xarray to implement functionality for DataArray
and Dataset
. If we aren't using a Variable
method as part of the implementation for Dataset/DataArray, then that is a good clue that it may not be necessary.
Co-Authored-By: Deepak Cherian <dcherian@users.noreply.github.com>
Co-Authored-By: Stephan Hoyer <shoyer@gmail.com>
Co-Authored-By: Deepak Cherian <dcherian@users.noreply.github.com>
Hi @vrx- do you have time to pick this up again? |
Would it be possible to add exclude_dims? I have a use case where I wanted to apply a function (for example fitting) along a dimension. I programmatically create a list of dimensions to stack to create 2D dataset. Then I loop over the stacked dimension and apply the function to last dimension. |
#3826 enables Can this also be closed? |
I'm working on issue #1029. Will try to add a test today. Suggestions welcome