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 transpose_coords option to DataArray.transpose #2556

Merged
merged 20 commits into from
May 21, 2019

Conversation

phausamann
Copy link
Contributor

@phausamann phausamann commented Nov 16, 2018

I've added the option transpose_coords to DataArray.transpose as described in #1856. It's False by default, as it breaks a couple of tests otherwise (TestConcatDataset.test_concat, test_apply_output_core_dimension and test_dot). I'm not sure whether fixing these tests to work with the new behavior should be part of the PR.

@pep8speaks
Copy link

pep8speaks commented Nov 16, 2018

Hello @phausamann! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-05-21 16:42:27 UTC

@shoyer
Copy link
Member

shoyer commented Nov 16, 2018

As a default, I think we want transpose_coords=None.

If transpose_coords is None and there are coordinates to transpose, we can issue a FutureWarning about how the default behavior of transpose_coords will switch to True in the future.

I'm not sure whether fixing these tests to work with the new behavior should be part of the PR.

Yes, this would be ideal. It would be fine to use transpose_coords=False explicitly in tests, but we should silence all warnings.

@phausamann
Copy link
Contributor Author

I've updated the method to issue the warning and fixed the failing tests (which was actually a bug in my implementation).

It would be fine to use transpose_coords=False explicitly in tests, but we should silence all warnings.

I'm not exactly sure how this works, there are a lot of tests where the warning is issued, especially calls to DataArray.T. Should I update all of these tests to transpose(..., transpose_coords=False)?

xarray/core/dataarray.py Outdated Show resolved Hide resolved
@shoyer
Copy link
Member

shoyer commented Nov 20, 2018

I'm not exactly sure how this works, there are a lot of tests where the warning is issued, especially calls to DataArray.T. Should I update all of these tests to transpose(..., transpose_coords=False)?

Yes, that would probably be the right call. Or maybe even switch to .transpose(transpose_coords=True) to future proof the behavior?

We try to avoid issuing warnings in xarray's own test suite so we notice issues (e.g., deprecations in upstream packages) when they arise. This also gives us some estimate of how much turmoil a change will cause for users -- if we end up with lots of internal warnings, then users will probably notice, too.

xarray/core/groupby.py Outdated Show resolved Hide resolved
@phausamann
Copy link
Contributor Author

phausamann commented Nov 22, 2018

I've changed all the transpose calls in the tests to transpose_coords=True. Other than that, there's some transpose calls in plot and groupby that I've updated, but I'm not sure whether they should be True, False or not updated at all (see above).

@phausamann
Copy link
Contributor Author

I've added a restore_coord_dims parameter to groupby, groupby_bins and resample and eliminated all warnings from the tests. The build failure seems to be inherited from the master branch.

@phausamann
Copy link
Contributor Author

@shoyer is this ready to be merged?

@phausamann phausamann changed the title [WIP] Add transpose_coords option to DataArray.transpose Add transpose_coords option to DataArray.transpose Apr 5, 2019
@StanczakDominik
Copy link
Contributor

Hi, just popping in - perhaps rebasing on top of the master branch would help move this along?

@shoyer
Copy link
Member

shoyer commented May 1, 2019

I just merged in master, let's see how that goes

@dcherian dcherian mentioned this pull request May 21, 2019
15 tasks
@phausamann
Copy link
Contributor Author

Looks like the build failures were only temporary, all the checks are passing now. I think this is good to go.

@shoyer shoyer merged commit 0811141 into pydata:master May 21, 2019
@shoyer
Copy link
Member

shoyer commented May 21, 2019

OK, in it goes!

Thanks for your patience @phausamann !

dcherian added a commit to dcherian/xarray that referenced this pull request May 29, 2019
* upstream/master:
  cfgrib is now part of conda-forge (pydata#2992)
  Add fill_value for concat and auto_combine (pydata#2964)
  Remove deprecated pytest.config usages (pydata#2988)
  Add transpose_coords option to DataArray.transpose (pydata#2556)
  Fix rolling.constuct() example (pydata#2967)
  Implement load_dataset() and load_dataarray() (pydata#2917)
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.

Option to make DataArray.transpose also transpose coords
4 participants