Fix broken from_local usage examples in backend module docstrings.#20
Merged
copybara-service[bot] merged 2 commits intoJul 20, 2026
Merged
Conversation
The usage examples in gnm_numpy.py, gnm_jax.py, gnm_pytorch.py and gnm_tensorflow.py call <module>.from_local(...), which does not exist (from_local is a classmethod on GNM), and reference GNMVersion.V3, which is not a member of GNMVersion (from_local takes GNMMajorVersion). Update all four examples to <module>.GNM.from_local(version=<module>.GNMMajorVersion.V3, ...) so they are copy-paste runnable. Also fix the remaining errors in the gnm_jax.py example (np.random.uniform takes size=, not shape=, and jax.grad argnums expects a sequence of ints; np.Array does not exist) and a stray space in the gnm_numpy.py docstring title. Verified by running the corrected gnm_numpy example against the bundled V3 head model: it now constructs the model and returns a (17821, 3) vertex array, where it previously raised AttributeError.
bednarikjan
approved these changes
Jul 16, 2026
bednarikjan
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fixes!
Contributor
Author
|
Thanks for the quick review! I have two more small fixes open whenever you get a chance-
No rush, and happy to adjust anything! |
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.
The usage examples in the module docstrings of
gnm_numpy.py,gnm_jax.py,gnm_pytorch.py, andgnm_tensorflow.pyare not runnable as written:<module>.from_local(...), but no module-levelfrom_localexists — it is a classmethod on the
GNMclass. Running the snippet raisesAttributeError: module 'gnm.shape.gnm_numpy' has no attribute 'from_local'.version=GNMVersion.V3, butV3is not a member ofGNMVersion(that enum has
V3_0), andGNM.from_localis annotated to takeGNMMajorVersion.This PR updates all four examples to
<module>.GNM.from_local(version=<module>.GNMMajorVersion.V3, variant=<module>.GNMVariant.HEAD)so they are copy-paste runnable.
It also fixes the remaining errors in the
gnm_jax.pyexample:np.random.uniformtakessize=, notshape=;np.Arraydoes not exist andjax.grad'sargnumsexpects ints, so it now usesargnums=(0, 1, 2, 3).Plus a stray space in the
gnm_numpy.pydocstring title.Verification: ran the corrected
gnm_numpyexample verbatim against thebundled V3 head model, it constructs the model and returns a
(17821, 3)vertex array, where the previous snippet raised
AttributeError. Docstring-onlychange; no behavior affected, all lines within 80 columns.