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

7 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-02-28 12:51 +1100

1""" 

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

3a consistent approach to typing is handled. 

4""" 

5from collections.abc import Hashable, Iterable 

6from typing import Optional, Union 

7 

8import pandas as pd 

9import xarray as xr 

10 

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

12# cases across the repository 

13FlexibleDimensionTypes = 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 

17XarrayLike = 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 

23FlexibleArrayType = Union[XarrayLike, pd.Series]