|
4 | 4 |
|
5 | 5 | from collections import OrderedDict |
6 | 6 | from collections.abc import Callable |
7 | | -from typing import Any, Protocol, runtime_checkable |
| 7 | +from typing import Any, Optional, Protocol, Union, runtime_checkable |
8 | 8 |
|
9 | 9 | try: |
10 | | - from typing import ParamSpec, TypeAlias, Union |
| 10 | + from typing import ParamSpec, TypeAlias |
11 | 11 | except ImportError: |
12 | | - from typing_extensions import ParamSpec, TypeAlias, Union |
| 12 | + from typing_extensions import ParamSpec, TypeAlias |
13 | 13 |
|
14 | 14 | import numpy as np |
15 | 15 |
|
|
23 | 23 | TraceT: TypeAlias = OrderedDict[str, Message] |
24 | 24 |
|
25 | 25 | # ArrayLike type has StaticScalar, StrictArrayT has everything except StaticScalars |
26 | | -StrictArrayT: TypeAlias = Union[np.ndarray, jax.Array] |
| 26 | +StrictArrayT = Union[np.ndarray, jax.Array] |
27 | 27 |
|
28 | 28 |
|
29 | 29 | @runtime_checkable |
@@ -94,18 +94,28 @@ def is_discrete(self) -> bool: ... |
94 | 94 | class TransformT(Protocol): |
95 | 95 | domain: ConstraintT = ... |
96 | 96 | codomain: ConstraintT = ... |
97 | | - _inv: "TransformT" = None |
| 97 | + _inv: Optional["TransformT"] = ... |
98 | 98 |
|
99 | | - def __call__(self, x: jax.Array) -> jax.Array: ... |
100 | | - def _inverse(self, y: jax.Array) -> jax.Array: ... |
| 99 | + def __call__(self, x: Union[jax.Array, Any]) -> Union[jax.Array, Any]: ... |
| 100 | + def _inverse(self, y: Union[jax.Array, Any]) -> Union[jax.Array, Any]: ... |
101 | 101 | def log_abs_det_jacobian( |
102 | | - self, x: jax.Array, y: jax.Array, intermediates=None |
103 | | - ) -> jax.Array: ... |
104 | | - def call_with_intermediates(self, x: jax.Array) -> tuple[jax.Array, None]: ... |
| 102 | + self, |
| 103 | + x: Union[jax.Array, Any], |
| 104 | + y: Union[jax.Array, Any], |
| 105 | + intermediates: Optional[Any] = None, |
| 106 | + ) -> Union[jax.Array, Any]: ... |
| 107 | + def call_with_intermediates( |
| 108 | + self, x: Union[jax.Array, Optional[Any]] |
| 109 | + ) -> tuple[Union[jax.Array, Any], Any]: ... |
105 | 110 | def forward_shape(self, shape: tuple[int, ...]) -> tuple[int, ...]: ... |
106 | 111 | def inverse_shape(self, shape: tuple[int, ...]) -> tuple[int, ...]: ... |
107 | 112 |
|
108 | 113 | @property |
109 | 114 | def inv(self) -> "TransformT": ... |
110 | 115 | @property |
111 | | - def sign(self) -> jax.Array: ... |
| 116 | + def sign(self) -> Union[ArrayLike, Any]: ... |
| 117 | + |
| 118 | + |
| 119 | +class UnusedParam(object): |
| 120 | + def __repr__(self): |
| 121 | + return "UnusedParam" |
0 commit comments