|
29 | 29 | # Array Utilities |
30 | 30 | ShapeType = Tuple[int, ...] |
31 | 31 |
|
32 | | -# Backend Types |
33 | | -ArrayType = Union[np.ndarray, "jax.numpy.ndarray", "torch.Tensor"] |
34 | | -ScalarType = Union[np.ndarray, "jax.numpy.ndarray", "torch.Tensor"] |
| 32 | +# Scalars, Arrays and Matrices |
| 33 | +ScalarType = "probnum.backend.ndarray" |
| 34 | +MatrixType = Union["probnum.backend.ndarray", "probnum.linops.LinearOperator"] |
35 | 35 |
|
| 36 | +# Random Number Generation |
36 | 37 | SeedType = Union[np.random.SeedSequence, "jax.random.PRNGKey"] |
37 | 38 |
|
38 | | -# ProbNum Types |
39 | | -MatrixType = Union[ArrayType, "probnum.linops.LinearOperator"] |
40 | | - |
41 | | -# Scalars, Arrays and Matrices |
42 | | -ScalarType = np.number |
43 | | -MatrixType = Union[np.ndarray, "probnum.linops.LinearOperator"] |
44 | 39 |
|
45 | 40 | ######################################################################################## |
46 | 41 | # Argument Types |
|
64 | 59 | """Type of a public API argument for supplying a shape. |
65 | 60 |
|
66 | 61 | Values of this type should always be converted into :class:`ShapeType` using the |
67 | | -function :func:`probnum.backend.as_scalar` before further internal processing.""" |
| 62 | +function :func:`probnum.backend.as_shape` before further internal processing.""" |
68 | 63 |
|
69 | | -DTypeLike = _NumPyDTypeLike |
| 64 | +DTypeLike = Union[_NumPyDTypeLike, "jax.numpy.dtype", "torch.dtype"] |
70 | 65 | """Type of a public API argument for supplying an array's dtype. |
71 | 66 |
|
72 | | -Values of this type should always be converted into :class:`np.dtype`\\ s before further |
73 | | -internal processing.""" |
| 67 | +Values of this type should always be converted into :class:`backend.dtype`\\ s using the |
| 68 | +function :func:`probnum.backend.as_dtype` before further internal processing.""" |
74 | 69 |
|
75 | 70 | _ArrayIndexLike = Union[ |
76 | 71 | int, |
77 | 72 | slice, |
78 | 73 | type(Ellipsis), |
79 | 74 | None, |
80 | | - np.newaxis, |
81 | | - np.ndarray, |
| 75 | + "probnum.backend.newaxis", |
| 76 | + "probnum.backend.ndarray", |
82 | 77 | ] |
83 | 78 | ArrayIndicesLike = Union[_ArrayIndexLike, Tuple[_ArrayIndexLike, ...]] |
84 | 79 | """Type of the argument to the :meth:`__getitem__` method of a NumPy-like array type |
85 | | -such as :class:`np.ndarray`, :class:`probnum.linops.LinearOperator` or |
| 80 | +such as :class:`probnum.backend.ndarray`, :class:`probnum.linops.LinearOperator` or |
86 | 81 | :class:`probnum.randvars.RandomVariable`.""" |
87 | 82 |
|
88 | 83 | # Scalars, Arrays and Matrices |
89 | | -ScalarLike = Union[int, float, complex, numbers.Number, np.number] |
| 84 | +ScalarLike = Union[ScalarType, int, float, complex, numbers.Number, np.number] |
90 | 85 | """Type of a public API argument for supplying a scalar value. |
91 | 86 |
|
92 | | -Values of this type should always be converted into :class:`np.number`\\ s using the |
93 | | -function :func:`probnum.utils.as_scalar` before further internal processing.""" |
| 87 | +Values of this type should always be converted into :class:`ScalarType`\\ s using |
| 88 | +the function :func:`probnum.backend.as_scalar` before further internal processing.""" |
94 | 89 |
|
95 | 90 | ArrayLike = Union[_NumPyArrayLike, "jax.numpy.ndarray", "torch.Tensor"] |
96 | 91 | """Type of a public API argument for supplying an array. |
97 | 92 |
|
98 | | -Values of this type should always be converted into :class:`np.ndarray`\\ s using |
99 | | -the function :func:`np.asarray` before further internal processing.""" |
| 93 | +Values of this type should always be converted into :class:`backend.ndarray`\\ s using |
| 94 | +the function :func:`probnum.backend.as_array` before further internal processing.""" |
100 | 95 |
|
101 | 96 | LinearOperatorLike = Union[ |
102 | 97 | ArrayLike, |
|
106 | 101 | """Type of a public API argument for supplying a finite-dimensional linear operator. |
107 | 102 |
|
108 | 103 | Values of this type should always be converted into :class:`probnum.linops.\\ |
109 | | -LinearOperator`\\ s using the function :func:`probnum.linops.aslinop` before further |
| 104 | +LinearOperator`\\ s using the function :func:`probnum.linops.as_linop` before further |
110 | 105 | internal processing.""" |
111 | 106 |
|
| 107 | +# Random Number Generation |
112 | 108 | SeedLike = Optional[int] |
| 109 | +"""Type of a public API argument for supplying the seed of a random number generator. |
| 110 | +
|
| 111 | +Values of this type should always be converted to :class:`SeedType` using the function |
| 112 | +:func:`probnum.backend.random.seed` before further internal processing.""" |
113 | 113 |
|
114 | 114 | ######################################################################################## |
115 | 115 | # Other Types |
|
0 commit comments