Skip to content

docs: add array shape dimensions to Normal distribution type hints#100

Open
professor314 wants to merge 2 commits into
lockwo:mainfrom
professor314:docs/add-array-dims-normal
Open

docs: add array shape dimensions to Normal distribution type hints#100
professor314 wants to merge 2 commits into
lockwo:mainfrom
professor314:docs/add-array-dims-normal

Conversation

@professor314

Copy link
Copy Markdown

Summary

Adds jaxtyping shape annotations to the Normal distribution class, replacing bare Array type hints with Float[Array, " *shape"] where appropriate.

Changes

  • Import Float from jaxtyping
  • Annotate loc and scale fields as Float[Array, " *shape"]
  • Annotate all method parameters and return types with shape dimensions
  • support returns Float[Array, ""] (scalar bounds)
  • All other methods use Float[Array, " *shape"] matching the event shape

Motivation

Addresses #35. Shape-annotated type hints make the API clearer for users reading docs or using IDE autocompletion, and enable more precise runtime checking via beartype in tests.

This PR covers the Normal distribution as a starting point. The same pattern can be applied to other distributions in follow-up PRs.

Testing

Type-annotation-only change. No behavioral changes. The existing test suite (normal_test.py) continues to pass.

@lockwo lockwo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs formatting

@professor314

Copy link
Copy Markdown
Author

Hey, sorry about the formatting. I ran the project's Black formatter and pushed a fix. I saw issue #35 and thought the Normal distribution would be a good starting point since it's the most commonly used one. Let me know if there's anything else that needs adjusting.

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

Successfully merging this pull request may close these issues.

2 participants