patrick-kidger / patrick-kidger/jaxtyping
Support for type checking dataclass properties
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
Suppose you have a dataclass:
@jaxtyped(typechecker=typechecker)
@dataclass
class MyDataclass:
x: Float[Array, "n"]
@property
def plus1(self) -> Float[Array, "n"]:
return self.x + 1.0
There is no way AFAIK how to enforce that "n" is derived from the class definition. Is there a way to enforce this? And is this a feature that would make sense? Note also symbolic shapes cannot be expressed with checking, eg. Float[Array, "n+1"] would fail as n is undefined in the function input.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing @jaxtyped(typechecker=typechecker) around dataclass fields and @property return annotations, then inspect how symbolic shape names are resolved. A complete result should establish whether class-derived dimensions and expressions such as "n+1" can be enforced, with tests covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100