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

Documentation talks about Dataset, example is for DataArray #6336

Closed
paapu88 opened this issue Mar 6, 2022 · 3 comments · Fixed by #6558
Closed

Documentation talks about Dataset, example is for DataArray #6336

paapu88 opened this issue Mar 6, 2022 · 3 comments · Fixed by #6558

Comments

@paapu88
Copy link

paapu88 commented Mar 6, 2022

What happened?

In the dev version of the documentation
https://docs.xarray.dev/en/latest/generated/xarray.Dataset.assign_coords.html

The page is about Dataset, but all the examples are for DataArray

What did you expect to happen?

Examples should be for Dataset, not for DataArray

Minimal Complete Verifiable Example

No response

Relevant log output

No response

Anything else we need to know?

No response

Environment

https://docs.xarray.dev/en/latest/generated/xarray.Dataset.assign_coords.html

@paapu88 paapu88 added bug needs triage Issue that has not been reviewed by xarray team member labels Mar 6, 2022
@andersy005 andersy005 added topic-documentation and removed needs triage Issue that has not been reviewed by xarray team member bug labels Mar 7, 2022
@gregbehm
Copy link
Contributor

The DataArray.assign_coords examples appear on the xarray.Dataset.assign_coords doc page because they're written in /xarray/core/common.py for the .assign_coords method of class DataWithCoords, the shared base class for Dataset and DataArray.

@andersy005 can you recommend a way to separate the Dataset and DataArray examples for methods shared by the same base class? This same problem affects other doc pages for common Dataset/DataArray methods.

Thanks, Greg

@gregbehm
Copy link
Contributor

gregbehm commented May 1, 2022

After further investigation, I think the easiest solution is to provide examples that cover both object types, DataArray and Dataset, analogous to the pandas.DataFrame and pandas.Series documentation, e.g. pandas.DataFrame.describe:

Examples

Describing a numeric Series.
...

Describing a DataFrame. By default only numeric fields are returned.
...

@max-sixty
Copy link
Collaborator

After further investigation, I think the easiest solution is to provide examples that cover both object types,

I agree, this would be very reasonable.

(For these methods that are basically the same between objects, it's nice to have at least one example for each to show that it works on each type, but otherwise it's fine to have the examples more focused on one object)

gregbehm pushed a commit to gregbehm/xarray that referenced this issue May 2, 2022
gregbehm pushed a commit to gregbehm/xarray that referenced this issue May 4, 2022
* remove np.random uses

* fix one copy-paste artifact 'description:  Temperature data'
gregbehm pushed a commit to gregbehm/xarray that referenced this issue May 4, 2022
* remove np.random uses

 * fix one copy-paste artifact 'description:  Temperature data'
gregbehm pushed a commit to gregbehm/xarray that referenced this issue May 4, 2022
dcherian pushed a commit that referenced this issue May 11, 2022
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
dcherian added a commit to dcherian/xarray that referenced this issue May 20, 2022
* main: (24 commits)
  Fix overflow issue in decode_cf_datetime for dtypes <= np.uint32 (pydata#6598)
  Enable flox in GroupBy and resample (pydata#5734)
  Add setuptools as dependency in ASV benchmark CI (pydata#6609)
  change polyval dim ordering (pydata#6601)
  re-add timedelta support for polyval (pydata#6599)
  Minor Dataset.map docstr clarification (pydata#6595)
  New inline_array kwarg for open_dataset (pydata#6566)
  Fix polyval overloads (pydata#6593)
  Restore old MultiIndex dropping behaviour (pydata#6592)
  [docs] add Dataset.assign_coords example (pydata#6336) (pydata#6558)
  Fix zarr append dtype checks (pydata#6476)
  Add missing space in exception message (pydata#6590)
  Doc Link to accessors list in extending-xarray.rst (pydata#6587)
  Fix Dataset/DataArray.isel with drop=True and scalar DataArray indexes (pydata#6579)
  Add some warnings about rechunking to the docs (pydata#6569)
  [pre-commit.ci] pre-commit autoupdate (pydata#6584)
  terminology.rst: fix link to Unidata's "netcdf_dataset_components" (pydata#6583)
  Allow string formatting of scalar DataArrays (pydata#5981)
  Fix mypy issues & reenable in tests (pydata#6581)
  polyval: Use Horner's algorithm + support chunked inputs (pydata#6548)
  ...
dcherian added a commit to headtr1ck/xarray that referenced this issue May 20, 2022
commit 398f1b6
Author: dcherian <[email protected]>
Date:   Fri May 20 08:47:56 2022 -0600

    Backward compatibility dask

commit bde40e4
Merge: 0783df3 4cae8d0
Author: dcherian <[email protected]>
Date:   Fri May 20 07:54:48 2022 -0600

    Merge branch 'main' into dask-datetime-to-numeric

    * main:
      concatenate docs style (pydata#6621)
      Typing for open_dataset/array/mfdataset and to_netcdf/zarr (pydata#6612)
      {full,zeros,ones}_like typing (pydata#6611)

commit 0783df3
Merge: 5cff4f1 8de7061
Author: dcherian <[email protected]>
Date:   Sun May 15 21:03:50 2022 -0600

    Merge branch 'main' into dask-datetime-to-numeric

    * main: (24 commits)
      Fix overflow issue in decode_cf_datetime for dtypes <= np.uint32 (pydata#6598)
      Enable flox in GroupBy and resample (pydata#5734)
      Add setuptools as dependency in ASV benchmark CI (pydata#6609)
      change polyval dim ordering (pydata#6601)
      re-add timedelta support for polyval (pydata#6599)
      Minor Dataset.map docstr clarification (pydata#6595)
      New inline_array kwarg for open_dataset (pydata#6566)
      Fix polyval overloads (pydata#6593)
      Restore old MultiIndex dropping behaviour (pydata#6592)
      [docs] add Dataset.assign_coords example (pydata#6336) (pydata#6558)
      Fix zarr append dtype checks (pydata#6476)
      Add missing space in exception message (pydata#6590)
      Doc Link to accessors list in extending-xarray.rst (pydata#6587)
      Fix Dataset/DataArray.isel with drop=True and scalar DataArray indexes (pydata#6579)
      Add some warnings about rechunking to the docs (pydata#6569)
      [pre-commit.ci] pre-commit autoupdate (pydata#6584)
      terminology.rst: fix link to Unidata's "netcdf_dataset_components" (pydata#6583)
      Allow string formatting of scalar DataArrays (pydata#5981)
      Fix mypy issues & reenable in tests (pydata#6581)
      polyval: Use Horner's algorithm + support chunked inputs (pydata#6548)
      ...

commit 5cff4f1
Merge: dfe200d 6144c61
Author: Maximilian Roos <[email protected]>
Date:   Sun May 1 15:16:33 2022 -0700

    Merge branch 'main' into dask-datetime-to-numeric

commit dfe200d
Author: dcherian <[email protected]>
Date:   Sun May 1 11:04:03 2022 -0600

    Minor cleanup

commit 35ed378
Author: dcherian <[email protected]>
Date:   Sun May 1 10:57:36 2022 -0600

    Support dask arrays in datetime_to_numeric
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants