Skip to content

Commit

Permalink
remove Union
Browse files Browse the repository at this point in the history
  • Loading branch information
coxipi committed Oct 25, 2024
1 parent 4148cde commit 818a108
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/xscen/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ def produce_horizon( # noqa: C901
----------
ds : xr.Dataset
Input dataset with a time dimension.
indicators : Union[str, os.PathLike, Sequence[Indicator], Sequence[Tuple[str, Indicator]], ModuleType]
indicators : str | os.PathLike | Sequence[Indicator] | Sequence[Tuple[str, Indicator]] | ModuleType
Indicators to compute. It will be passed to the `indicators` argument of `xs.compute_indicators`.
periods : list of str or list of lists of str, optional
Either [start, end] or list of [start_year, end_year] for the period(s) to be evaluated.
Expand Down
4 changes: 2 additions & 2 deletions src/xscen/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def update(
Parameters
----------
df : Union[DataCatalog, intake_esm.esm_datastore, pd.DataFrame, pd.Series, Sequence[pd.Series]], optional
df : DataCatalog | intake_esm.esm_datastore | pd.DataFrame | pd.Series | Sequence[pd.Series], optional
Data to be added to the catalog. If None, nothing is added, but the catalog is still updated.
"""
# Append the new DataFrame or Series
Expand Down Expand Up @@ -999,7 +999,7 @@ def unstack_id(df: pd.DataFrame | ProjectCatalog | DataCatalog) -> dict:
Parameters
----------
df : Union[pd.DataFrame, ProjectCatalog, DataCatalog]
df : pd.DataFrame | ProjectCatalog | DataCatalog
Either a Project/DataCatalog or a pandas DataFrame.
Returns
Expand Down
8 changes: 3 additions & 5 deletions src/xscen/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from copy import deepcopy
from pathlib import Path
from types import ModuleType
from typing import Union


import numpy as np
import xarray as xr
Expand Down Expand Up @@ -332,7 +330,7 @@ def properties_and_measures( # noqa: C901
----------
ds : xr.Dataset
Input dataset.
properties : Union[str, os.PathLike, Sequence[Indicator], Sequence[tuple[str, Indicator]], ModuleType]
properties : str | os.PathLike | Sequence[Indicator] | Sequence[tuple[str, Indicator]] | ModuleType
Path to a YAML file that instructs on how to calculate properties.
Can be the indicator module directly, or a sequence of indicators or a sequence of
tuples (indicator name, indicator) as returned by `iter_indicators()`.
Expand Down Expand Up @@ -535,7 +533,7 @@ def measures_heatmap(


def measures_improvement(
meas_datasets: Union[list[xr.Dataset], dict],
meas_datasets: list[xr.Dataset] | dict,
dim: str | Sequence[str] | None = None,
to_level: str = "diag-improved",
) -> xr.Dataset:
Expand All @@ -544,7 +542,7 @@ def measures_improvement(
Parameters
----------
meas_datasets: list of xr.Dataset or dict
meas_datasets: list[xr.Dataset] | dict
List of 2 datasets: Initial dataset of measures and final (improved) dataset of measures.
Both datasets must have the same variables.
It is also possible to pass a dictionary where the values are the datasets and the key are not used.
Expand Down
4 changes: 2 additions & 2 deletions src/xscen/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def compute_indicators( # noqa: C901
----------
ds : xr.Dataset
Dataset to use for the indicators.
indicators : Union[str, os.PathLike, Sequence[Indicator], Sequence[tuple[str, Indicator]], ModuleType]
indicators : str | os.PathLike | Sequence[Indicator] | Sequence[tuple[str, Indicator]] | ModuleType
Path to a YAML file that instructs on how to calculate missing variables.
Can also be only the "stem", if translations and custom indices are implemented.
Can be the indicator module directly, or a sequence of indicators or a sequence of
Expand Down Expand Up @@ -349,7 +349,7 @@ def select_inds_for_avail_vars(
----------
ds : xr.Dataset
Dataset to use for the indicators.
indicators : Union[str, os.PathLike, Sequence[Indicator], Sequence[Tuple[str, Indicator]]]
indicators : str | os.PathLike | Sequence[Indicator] | Sequence[Tuple[str, Indicator]]
Path to a YAML file that instructs on how to calculate indicators.
Can also be only the "stem", if translations and custom indices are implemented.
Can be the indicator module directly, or a sequence of indicators or a sequence of
Expand Down

0 comments on commit 818a108

Please sign in to comment.