mirror of
https://github.com/wassname/jaxtyping.git
synced 2026-09-09 11:24:55 +08:00
Make test/helpers.py a relative import
This commit is contained in:
@@ -19,10 +19,11 @@
|
||||
|
||||
import jax.numpy as jnp
|
||||
import pytest
|
||||
from helpers import ParamError
|
||||
|
||||
from jaxtyping import f32
|
||||
|
||||
from .helpers import ParamError
|
||||
|
||||
|
||||
def g(x: f32[" b"]):
|
||||
pass
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
|
||||
import jax.numpy as jnp
|
||||
import pytest
|
||||
from helpers import ParamError
|
||||
|
||||
from jaxtyping import f32
|
||||
|
||||
from .helpers import ParamError
|
||||
|
||||
|
||||
def g(x: f32[" b"]):
|
||||
pass
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
|
||||
import jax.numpy as jnp
|
||||
import pytest
|
||||
from helpers import ParamError
|
||||
|
||||
from jaxtyping import f32
|
||||
|
||||
from ..helpers import ParamError
|
||||
|
||||
|
||||
def g(x: f32[" b"]):
|
||||
pass
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
|
||||
import jax.numpy as jnp
|
||||
import pytest
|
||||
from helpers import ParamError
|
||||
|
||||
from jaxtyping import f32
|
||||
|
||||
from .helpers import ParamError
|
||||
|
||||
|
||||
def g(x: f32[" b"]):
|
||||
pass
|
||||
|
||||
+2
-1
@@ -20,10 +20,11 @@
|
||||
import jax.numpy as jnp
|
||||
import jax.random as jr
|
||||
import pytest
|
||||
from helpers import ParamError, ReturnError
|
||||
|
||||
from jaxtyping import Array, f, f32, jaxtyped
|
||||
|
||||
from .helpers import ParamError, ReturnError
|
||||
|
||||
|
||||
def test_basic(typecheck):
|
||||
@jaxtyped
|
||||
|
||||
@@ -24,9 +24,9 @@ from jaxtyping import install_import_hook
|
||||
|
||||
def test_import_hook_typeguard():
|
||||
hook = install_import_hook(
|
||||
"import_hook_tester_typeguard", ("typeguard", "typechecked")
|
||||
"test.import_hook_tester_typeguard", ("typeguard", "typechecked")
|
||||
)
|
||||
import import_hook_tester_typeguard # noqa: F401
|
||||
from . import import_hook_tester_typeguard # noqa: F401
|
||||
|
||||
hook.uninstall()
|
||||
|
||||
@@ -38,26 +38,26 @@ def test_import_hook_beartype():
|
||||
pass
|
||||
else:
|
||||
hook = install_import_hook(
|
||||
"import_hook_tester_beartype", ("beartype", "beartype")
|
||||
"test.import_hook_tester_beartype", ("beartype", "beartype")
|
||||
)
|
||||
import import_hook_tester_beartype # noqa: F401
|
||||
from . import import_hook_tester_beartype # noqa: F401
|
||||
|
||||
hook.uninstall()
|
||||
|
||||
|
||||
def test_import_hook_transitive():
|
||||
hook = install_import_hook(
|
||||
"import_hook_tester_transitive", ("typeguard", "typechecked")
|
||||
"test.import_hook_tester_transitive", ("typeguard", "typechecked")
|
||||
)
|
||||
import import_hook_tester_transitive # noqa: F401
|
||||
from . import import_hook_tester_transitive # noqa: F401
|
||||
|
||||
hook.uninstall()
|
||||
|
||||
|
||||
def test_import_hook_broken_checker():
|
||||
hook = install_import_hook(
|
||||
"import_hook_tester_broken_checker", ("jaxtyping", "does_not_exist")
|
||||
"test.import_hook_tester_broken_checker", ("jaxtyping", "does_not_exist")
|
||||
)
|
||||
with pytest.raises(AttributeError):
|
||||
import import_hook_tester_broken_checker # noqa: F401
|
||||
from . import import_hook_tester_broken_checker # noqa: F401
|
||||
hook.uninstall()
|
||||
|
||||
+2
-1
@@ -24,10 +24,11 @@ import jax
|
||||
import jax.numpy as jnp
|
||||
import jax.random as jr
|
||||
import pytest
|
||||
from helpers import make_mlp, ParamError
|
||||
|
||||
from jaxtyping import f, jaxtyped, PyTree
|
||||
|
||||
from .helpers import make_mlp, ParamError
|
||||
|
||||
|
||||
def test_direct(typecheck):
|
||||
@typecheck
|
||||
|
||||
Reference in New Issue
Block a user