Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate using annotations with typeguard-style instrumentation #87

Closed
dkamm opened this issue May 23, 2023 · 2 comments
Closed

Evaluate using annotations with typeguard-style instrumentation #87

dkamm opened this issue May 23, 2023 · 2 comments

Comments

@dkamm
Copy link

dkamm commented May 23, 2023

Hey @patrick-kidger!

I got this idea through our discussion in agronholm/typeguard#353. Wanted to create an issue here since it's unrelated to typeguard.

What if jaxtyping had its own typeguard-style instrumentation?

We could write annotations like Float[T, S] = Annotated[T, Shape(S), DType("Float")], and the instrumentation could consume them to validate.

Pros

Cons

  • It's instrumentation
  • Could be overkill
@dkamm dkamm changed the title Evaluate using typeguard-style instrumentation Evaluate using annotations with typeguard-style instrumentation May 23, 2023
@patrick-kidger
Copy link
Owner

That is to say, you're proposing to write an entirely new runtime type checker? That is what would be required, in order to handle cases like tuple[Float[Array, "foo"], ...], in which the jaxtyping annotations are nested inside arbitrarily many other annotations. That seems like a lot of work when we already have both typeguard and beartype which are mostly-good-enough already.

I believe the Float as Annotated hack will always be required for static type checking compatibility.

@dkamm
Copy link
Author

dkamm commented Jun 1, 2023

Good point- closing

@dkamm dkamm closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants