Sitelet https://github.com/pypose/pypose/pull/383
Skip to content

Better type annotation for LieType.Mul method. - #383

Merged
wang-chen merged 4 commits into
pypose:mainfrom
MarkChenYutian:MarkChenYutian/type-spec-fix
Dec 20, 2025
Merged

wang-chen merged 4 commits into
pypose:mainfrom
MarkChenYutian:MarkChenYutian/type-spec-fix

Conversation

@MarkChenYutian

Copy link
Copy Markdown
Member

Improved the type annotation for a better static analysis experience. Following the description of pypose.mul method.

image

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MarkChenYutian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the type annotations for the LieType.Mul method within the pypose library. By leveraging Python's @overload decorator, the changes provide more specific return type hints depending on the input types, thereby improving the accuracy of static analysis tools and making the code easier to understand and maintain.

Highlights

  • Type Annotation Improvement: Enhanced the type annotations for the LieType.Mul method to provide more precise type hints for static analysis.
  • Overload Decorator Usage: Introduced the @overload decorator from Python's typing module to define distinct signatures for the Mul method based on the type of its Y argument.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request aims to improve type annotations for the LieType.Mul method by using @overload. While this is a good initiative for better static analysis, the current implementation of the overloads introduces an incorrect type hint for the case of multiplying a Lie Algebra by a Tensor. I've left a specific comment with a suggestion to correct this, ensuring the type hints are accurate for all cases.

Comment thread pypose/lietensor/lietensor.py Outdated
@MarkChenYutian

MarkChenYutian commented Dec 8, 2025 •

Copy link
Copy Markdown
Member Author

After applying the patch the static analyzer can distinguish different cases of @.

image

@MarkChenYutian

Copy link
Copy Markdown
Member Author

@wang-chen Hi I've fixed the problem mentioned by Gemini above by setting type of Act as:

Act (x: LieTensor, p: Tensor) -> LieTensor | Tensor

@wang-chen
wang-chen merged commit 0712511 into pypose:main Dec 20, 2025
4 checks passed
zitongzhan pushed a commit that referenced this pull request Mar 17, 2026
* Better type annotation for Mul method.

* More specified type spec.

---------

Co-authored-by: Chen Wang <chenw@sairlab.org>
wang-chen added a commit that referenced this pull request Apr 8, 2026
* [politics] avoid inplace operations

* [politics] avoid bmv in pcg

* [misc] remove the auto registered csr mm

* [optimizer] add the sparse interface

* [ui] add weight unsupported warning

* [pcg] minor bug when preconditioner is not supplied
- fix the output format of cg

* Raise explicit exception on optimizing w/ inference_mode. (#382)

* Raise explicit exception on optimizing w/ inference_mode.

* Minor fixes

* Better type annotation for `LieType.Mul` method. (#383)

* Better type annotation for Mul method.

* More specified type spec.

---------

Co-authored-by: Chen Wang <chenw@sairlab.org>

* Bump version from 0.7.3 to 0.7.4

Signed-off-by: Chen Wang <chenw@sairlab.org>

* Update setup.py for description and include python 3.12 and

* update installation command for editable mode (#385)

* Highlights
- Installation Command Update: The editable installation command in README.md has been updated from the deprecated python setup.py develop to the modern pip install -e ..
- Python Version Support: The setup.py file has been updated to declare support for Python versions 3.13 and 3.14, expanding compatibility for future environments.

* Bump version to 0.7.5

Signed-off-by: Chen Wang <chenw@sairlab.org>

* [test] clean up csr missing dispatch mess

* [refactor] use the imported jacobian

* add test case

* dense and sparse live in the same step

* the unsqueeze is no longer needed

* add citation

* [politics] simplify

* add example

* add ba example

* remove the dynamic loading from bae

* update sparse LM to PGO example

* make pcg, TrackingTensor, and map_transform all pp api

* [politics] use Track

* [trim_SE3] update to simplified bae api

* [politics] pp owner require simple example

* simplify the example and remove `trim_SE3` from pp

* change to sair-lab/bae

* rename `parallel_for_sparse_jacobian`

* [example] print loss per-iteration

* update doc

* [example] move bundle adjustment to ba

* add version guard

* [init] update the bae install command

* remaining ba path change

* remove doc redundant subsection title

* annotate lietype in comment

* change section title to autograd

* autograd summery page

* avoid residual

---------

Signed-off-by: Chen Wang <chenw@sairlab.org>
Co-authored-by: Yutian Chen <yutianch@andrew.cmu.edu>
Co-authored-by: Chen Wang <chenw@sairlab.org>
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