Skip to content

Description of coords type in documentation contradicts the example following it. #10118

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

Open
2 of 5 tasks
dorchard opened this issue Mar 13, 2025 · 2 comments
Open
2 of 5 tasks

Comments

@dorchard
Copy link

dorchard commented Mar 13, 2025

What happened?

The data structures documentation in user guide states that:

  • coords: a list or dictionary of coordinates. If a list, it should be a
    list of tuples where the first element is the dimension name and the second
    - ``coords``: a list or dictionary of coordinates. If a list, it should be a
    list of tuples where the first element is the dimension name and the second
    element is the corresponding coordinate array_like object.

But the example immediately following it has a list of coords that is not a list of tuples:

locs = ["IA", "IL", "IN"]
times = pd.date_range("2000-01-01", periods=4)
foo = xr.DataArray(data, coords=[times, locs], dims=["time", "space"])

instead [times, locs] is a just a list of lists.

locs = ["IA", "IL", "IN"]
times = pd.date_range("2000-01-01", periods=4)
foo = xr.DataArray(data, coords=[times, locs], dims=["time", "space"])

I believe the code is correct though so just the description of coords needs an update and should be clear that if you have just a list of coordinate lists, then the order of the outer list should match the order of the dims list.

What did you expect to happen?

Example not to contradict the description of the type.

Minimal Complete Verifiable Example

N/A

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

N/A

Anything else we need to know?

No response

Environment

@dorchard dorchard added bug needs triage Issue that has not been reviewed by xarray team member labels Mar 13, 2025
Copy link

welcome bot commented Mar 13, 2025

Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!

@TomNicholas TomNicholas added topic-documentation and removed needs triage Issue that has not been reviewed by xarray team member labels Mar 13, 2025
@max-sixty
Copy link
Collaborator

Good point!

I think the docs in the __init__ are correct, so we could just remove the incorrect description from the docs.

A PR would be v welcome if you'd be up for it...

coords : :py:class:`~xarray.Coordinates` or dict-like, optional

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

No branches or pull requests

3 participants