zero.types

Types used throughout Zero.

zero.types.PathLike = typing.Union[pathlib.Path, bytes, str]
zero.types.ArrayIndex = typing.Union[int, slice, typing.List[int], numpy.ndarray]
zero.types.TensorIndex = typing.Union[int, slice, typing.List[int], numpy.ndarray, torch.Tensor]
zero.types.Recursive = typing.Union[~T, typing.Tuple[_ForwardRef('Recursive'), ...], typing.List[_ForwardRef('Recursive')], typing.Dict[typing.Any, _ForwardRef('Recursive')]]

Note

The following values are all “instances” of Recursive[int]:

0
(0, 1)
[0, 1, 2]
{'a': 0, 1: 2}
[[[0], (1, 2, (3,)), {'a': {'b': [4]}}]]

from collections import namedtuple
Point = namedtuple('Point', ['x', 'y'])
Point(0, 1)  # also `Recursive[int]`
zero.types.JSON = typing.Union[NoneType, int, float, str, typing.List[_ForwardRef('JSON')], typing.Mapping[str, _ForwardRef('JSON')]]

Note

The following values are all “instances” of JSON:

True
0
1.0
'abc'
[0, 1.0]
{'a': [0, 1.0], 'b': False, 'c': 'abc'}
zero.types.Device = typing.Union[torch.device, int, str, NoneType]