1from __future__ import annotations
2
3from collections.abc import Iterable, Mapping
4from datetime import date, datetime, timedelta
5from typing import Any, Optional, Union, Tuple, List, Dict
6
7from numpy import ndarray # TODO use ArrayLike?
8from pandas import Series, Index, Timestamp, Timedelta
9from matplotlib.colors import Colormap, Normalize
10
11
12ColumnName = Union[
13 str, bytes, date, datetime, timedelta, bool, complex, Timestamp, Timedelta
14]
15Vector = Union[Series, Index, ndarray]
16
17VariableSpec = Union[ColumnName, Vector, None]
18VariableSpecList = Union[List[VariableSpec], Index, None]
19
20# A DataSource can be an object implementing __dataframe__, or a Mapping
21# (and is optional in all contexts where it is used).
22# I don't think there's an abc for "has __dataframe__", so we type as object
23# but keep the (slightly odd) Union alias for better user-facing annotations.
24DataSource = Union[object, Mapping, None]
25
26OrderSpec = Union[Iterable, None] # TODO technically str is iterable
27NormSpec = Union[Tuple[Optional[float], Optional[float]], Normalize, None]
28
29# TODO for discrete mappings, it would be ideal to use a parameterized type
30# as the dict values / list entries should be of specific type(s) for each method
31PaletteSpec = Union[str, list, dict, Colormap, None]
32DiscreteValueSpec = Union[dict, list, None]
33ContinuousValueSpec = Union[
34 Tuple[float, float], List[float], Dict[Any, float], None,
35]
36
37
38class Default:
39 def __repr__(self):
40 return "<default>"
41
42
43class Deprecated:
44 def __repr__(self):
45 return "<deprecated>"
46
47
48default = Default()
49deprecated = Deprecated()