-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate TypeVars in a single place (#5569)
* Consolidate type bounds in a single place * More consolidation * Update xarray/core/types.py Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> * Update xarray/core/types.py Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> * Rename T_DSorDA to T_Xarray * Update xarray/core/weighted.py Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> * Update xarray/core/rolling_exp.py Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> * . Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
116 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, TypeVar, Union | ||
|
||
import numpy as np | ||
|
||
if TYPE_CHECKING: | ||
from .common import DataWithCoords | ||
from .dataarray import DataArray | ||
from .dataset import Dataset | ||
from .groupby import DataArrayGroupBy, GroupBy | ||
from .npcompat import ArrayLike | ||
from .variable import Variable | ||
|
||
try: | ||
from dask.array import Array as DaskArray | ||
except ImportError: | ||
DaskArray = np.ndarray | ||
|
||
T_Dataset = TypeVar("T_Dataset", bound="Dataset") | ||
T_DataArray = TypeVar("T_DataArray", bound="DataArray") | ||
T_Variable = TypeVar("T_Variable", bound="Variable") | ||
# Maybe we rename this to T_Data or something less Fortran-y? | ||
T_Xarray = TypeVar("T_Xarray", "DataArray", "Dataset") | ||
T_DataWithCoords = TypeVar("T_DataWithCoords", bound="DataWithCoords") | ||
|
||
ScalarOrArray = Union["ArrayLike", np.generic, np.ndarray, "DaskArray"] | ||
DsCompatible = Union["Dataset", "DataArray", "Variable", "GroupBy", "ScalarOrArray"] | ||
DaCompatible = Union["DataArray", "Variable", "DataArrayGroupBy", "ScalarOrArray"] | ||
VarCompatible = Union["Variable", "ScalarOrArray"] | ||
GroupByIncompatible = Union["Variable", "GroupBy"] |
Oops, something went wrong.