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 type of .assign_coords #8495

Merged
merged 6 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pandas as pd

from xarray.core import dtypes, duck_array_ops, formatting, formatting_html, ops
from xarray.core.coordinates import Coordinates
from xarray.core.indexing import BasicIndexer, ExplicitlyIndexed
from xarray.core.options import OPTIONS, _get_keep_attrs
from xarray.core.parallelcompat import get_chunked_array_type, guess_chunkmanager
Expand Down Expand Up @@ -474,7 +475,7 @@ def _calc_assign_results(

def assign_coords(
self,
coords: Mapping[Any, Any] | None = None,
coords: Mapping[Any, Any] | Coordinates | None = None,
max-sixty marked this conversation as resolved.
Show resolved Hide resolved
**coords_kwargs: Any,
) -> Self:
"""Assign new coordinates to this object.
Expand All @@ -484,7 +485,7 @@ def assign_coords(

Parameters
----------
coords : dict-like or None, optional
coords : dict-like or Coordinates, optional
A dict where the keys are the names of the coordinates
with the new values to assign. If the values are callable, they are
computed on this object and assigned to new coordinate variables.
Expand Down Expand Up @@ -593,14 +594,6 @@ def assign_coords(
Attributes:
description: Weather-related data

Notes
-----
Since ``coords_kwargs`` is a dictionary, the order of your arguments
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is no longer the case in modern python...

may not be preserved, and so the order of the new variables is not well
defined. Assigning multiple variables within the same ``assign_coords``
is possible, but you cannot reference other variables created within
the same ``assign_coords`` call.

See Also
--------
Dataset.assign
Expand Down
Loading