Coverage for src/scores/typing.py: 100%

1"""

2 This module contains various compound or union types which can be used across the codebase to ensure

3 a consistent approach to typing is handled.

4"""

5 from collections.abc import Hashable, Iterable

6 from typing import Optional, Union

7

8 import pandas as pd

9 import xarray as xr

10

11# Flexible Dimension Types should be used for preserve_dims and reduce_dims in all

12# cases across the repository

13 FlexibleDimensionTypes = Optional[Iterable[Hashable]]

14

15# Xarraylike data types should be used for all forecast, observed and weights

16# However currently some are specified as DataArray only

17 XarrayLike = Union[xr.DataArray, xr.Dataset]

18

19# These type hint values *may* be used for various arguments across the

20# scores repository but are not establishing a standard or expectation beyond

21# the function they are used in

22

23 FlexibleArrayType = Union[XarrayLike, pd.Series]