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

fix the name of the return value in the swap_dims docstrings #3329

Merged
merged 1 commit into from
Sep 21, 2019

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Sep 21, 2019

  • Tests added
  • Passes black . && mypy . && flake8
  • Fully documented, including whats-new.rst for all changes and api.rst for new API

@dcherian
Copy link
Contributor

Thanks @keewis I just remembered issue #2838. I am sorry I didn't point this out earlier. It looks like we want to change this from swap_dims to rename_dims. Are you up for doing that?

I think the way to proceed would be to change the name of this method to rename_dims; add a new swap_dims method that raises a DeprecationWarning and calls the new rename_dims

@keewis
Copy link
Collaborator Author

keewis commented Sep 21, 2019

from what I understand of how swap_dims works, that name change does not really reflect what it does:

>>> a = xr.DataArray(data=[0, 1], coords={"x": ["a", "b"], "x2": ("x", [0, 1])}, dims="x")
>>> a
<xarray.DataArray (x: 2)>
array([0, 1])
Coordinates:
  * x        (x) <U1 'a' 'b'
    x2       (x) int64 0 1
>>> a.swap_dims({"x": "x2"})
<xarray.DataArray (x2: 2)>
array([0, 1])
Coordinates:
    x        (x2) <U1 'a' 'b'
  * x2       (x2) int64 0 1

I think that rather than renaming swap_dims, an entirely new function named rename_dims (which Dataset got in #3045) would be better? Also, from #2838 it seems that adding examples to swap_dims should help?

@keewis
Copy link
Collaborator Author

keewis commented Sep 21, 2019

oh, and I would certainly like to extend this PR to fix this (but only once #3238 is done)

@dcherian
Copy link
Contributor

😳

@dcherian dcherian merged commit 4617e68 into pydata:master Sep 21, 2019
@keewis
Copy link
Collaborator Author

keewis commented Sep 21, 2019

say, would it help to add my example to the docstring? If so, should I open a new PR for that?

@dcherian
Copy link
Contributor

Yes and yes.

@keewis keewis deleted the fix-swap_dims-docs branch September 21, 2019 21:44
dcherian added a commit that referenced this pull request Sep 24, 2019
* upstream/master: (43 commits)
  Add hypothesis support to related projects (#3335)
  More doc fixes (#3333)
  Improve the documentation of swap_dims (#3331)
  fix the doc names of the return value of swap_dims (#3329)
  Fix isel performance regression (#3319)
  Allow weakref (#3318)
  Clarify that "scatter" is a plotting method in what's new. (#3316)
  Fix whats-new date :/
  Revert to dev version
  Release v0.13.0
  auto_combine deprecation to 0.14 (#3314)
  Deprecation: groupby, resample default dim. (#3313)
  Raise error if cmap is list of colors (#3310)
  Refactor concat to use merge for non-concatenated variables (#3239)
  Honor `keep_attrs` in DataArray.quantile (#3305)
  Fix DataArray api doc (#3309)
  Accept int value in head, thin and tail (#3298)
  ignore h5py 2.10.0 warnings and fix invalid_netcdf warning test. (#3301)
  Update why-xarray.rst with clearer expression (#3307)
  Compat and encoding deprecation to 0.14 (#3294)
  ...
dcherian added a commit to dcherian/xarray that referenced this pull request Oct 3, 2019
* upstream/master:
  Remove setting of universal wheels (pydata#3367)
  Revisit # noqa annotations (pydata#3359)
  Fix codecov.io upload on Windows (pydata#3360)
  Add how do I ... section (pydata#3357)
  Add glossary to documentation (pydata#3352)
  Documentation improvements (pydata#3328)
  Remove `complex.nc` from built docs (pydata#3353)
  Fix DataArray.to_netcdf type annotation (pydata#3325)
  CI test suites with pinned minimum dependencies (pydata#3346)
  Bugfix/plot accept coord dim (pydata#3345)
  CI environments overhaul (pydata#3340)
  Add hypothesis support to related projects (pydata#3335)
  More doc fixes (pydata#3333)
  Improve the documentation of swap_dims (pydata#3331)
  fix the doc names of the return value of swap_dims (pydata#3329)
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.

2 participants