mirror of
https://github.com/wassname/jaxtyping.git
synced 2026-09-10 12:14:04 +08:00
Adding a test for generator support (#171)
* Add a test for generators * Remove output annotations from decorators Also guarded torch imports for better compatibility with requirements.txt * Add flag to the main meta class to skip the typecheck * Return to the old solution * Make async tests work * Minor adjustments/fixing typos * Correct Python path for new tests * Remove some jax-dependent code * Implement equality for MetaArrays * Make all Dim variations frozen dataclasses * Shorten AbstractArray methods * Final touches * Removing get_origin use * Update tests with @jaxtyp
This commit is contained in:
committed by
Patrick Kidger
parent
17ea4b13eb
commit
172b83b4fc
@@ -0,0 +1,35 @@
|
||||
from typing import Tuple, Union
|
||||
|
||||
import pytest
|
||||
|
||||
from jaxtyping import (
|
||||
Array,
|
||||
Float,
|
||||
Float32,
|
||||
Integer,
|
||||
PRNGKeyArray,
|
||||
PyTree,
|
||||
Shaped,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"make_fn",
|
||||
[
|
||||
lambda: Float[Array, "4"],
|
||||
lambda: Float32[Array, ""],
|
||||
lambda: Integer[Array, "1 2 3"],
|
||||
lambda: Shaped[PRNGKeyArray, "2"],
|
||||
lambda: Float[float, "#*shape"],
|
||||
lambda: PyTree[int],
|
||||
lambda: PyTree[Float[Array, ""]],
|
||||
lambda: PyTree[Float32[Array, "*m b c"]],
|
||||
lambda: PyTree[PyTree[Float32[Array, "1 2 b *"]]],
|
||||
lambda: PyTree[Union[str, Float32[Array, "1"]]],
|
||||
lambda: PyTree[
|
||||
Tuple[int, float, Float[Array, ""], PyTree[Union[Float[Array, ""], float]]]
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_equals(make_fn):
|
||||
assert make_fn() == make_fn()
|
||||
Reference in New Issue
Block a user