Improve docstrings and type annotations in jax_utils.py#2022
Closed
irhyl wants to merge 1 commit intogoogle-deepmind:mainfrom
Closed
Improve docstrings and type annotations in jax_utils.py#2022irhyl wants to merge 1 commit intogoogle-deepmind:mainfrom
irhyl wants to merge 1 commit intogoogle-deepmind:mainfrom
Conversation
- Add Google-style docstrings to get_dtype, get_np_dtype, get_int_dtype, and _init_pytree - Fix return type annotations: use type[jnp.float32] | type[jnp.float64] instead of type(jnp.float32) for dtype-returning functions - Add parameter and return type hints to _init_pytree and its inner init_array function
Nush395
reviewed
Mar 27, 2026
|
|
||
| def _init_pytree(t): | ||
| def _init_pytree(t: PyTree) -> PyTree: | ||
| """Initializes a pytree of `ShapeDtypeStruct` leaves into concrete arrays. |
Collaborator
There was a problem hiding this comment.
a one line docstring is sufficient for this private function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves developer experience and static analysis for
jax_utils.pyby adding missing docstrings and correcting type annotations.Changes
torax/_src/jax_utils.pyget_dtype,get_np_dtype,get_int_dtype,_init_pytreetype(jnp.float32)(a runtime value) totype[jnp.float32] | type[jnp.float64](a proper type hint)_init_pytree(t: PyTree) -> PyTreeand its innerinit_arrayTesting
All 15 existing
jax_utils_test.pytests continue to pass.