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

Random instances / Hypothesis-like generation #189

Open
srush opened this issue Mar 7, 2024 · 3 comments
Open

Random instances / Hypothesis-like generation #189

srush opened this issue Mar 7, 2024 · 3 comments
Labels
question User queries

Comments

@srush
Copy link

srush commented Mar 7, 2024

Was just curious if anyone had built a way to use jaxtyping to generate random instances of the right shape specified by the constraints? Alternatively if I wanted to build that how might I hook into the constraint system.

https://hypothesis.readthedocs.io/en/latest/numpy.html#array-api

@patrick-kidger
Copy link
Owner

I've definitely heard this idea discussed a couple of times, but I don't know that anyone has both done it and published it open-source.

At least with JAX it should be particularly easy, as one could then do a jax.eval_shape call to abstractly evaluate the function, performing all shape-checks without having to evaluate any actual code or knowing what are legal values to pass in.

@patrick-kidger patrick-kidger added the question User queries label Mar 7, 2024
@srush
Copy link
Author

srush commented Mar 7, 2024

okay, I might try something up. any recs on how to best get out the constraints?

@patrick-kidger
Copy link
Owner

As in, given an x defined by x = Float[Array, "foo bar"], you're asking how to obtain the "foo bar" from x?

This is accesible as x.dim_str, although that's only semi-public API. You could also look at x.dims to get the parsed result, although that's again only semi-public as the types it contains are not public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User queries
Projects
None yet
Development

No branches or pull requests

2 participants