Added with jaxtyped("context"):, for now undocumented.

This commit is contained in:
Patrick Kidger
2023-11-07 11:34:40 -08:00
parent 260fb36876
commit e4a93ee218
2 changed files with 25 additions and 1 deletions
+11 -1
View File
@@ -1,6 +1,8 @@
import abc
from jaxtyping import jaxtyped
import jax.random as jr
from jaxtyping import Array, Float, jaxtyped
class M(metaclass=abc.ABCMeta):
@@ -75,3 +77,11 @@ def test_abstractmethod():
def test_property():
assert N().j1 == 3
assert N().j2 == 4
def test_context(getkey):
a = jr.normal(getkey(), (3, 4))
b = jr.normal(getkey(), (5,))
with jaxtyped("context"):
assert isinstance(a, Float[Array, "foo bar"])
assert not isinstance(b, Float[Array, "foo"])