Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerate parameter types in documentation from python typehints #2125

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

gpleiss
Copy link
Member

@gpleiss gpleiss commented Sep 7, 2022

For example: if the method is...

def forward(self, x1: Tensor, x2: Optional[Tensor]) -> Union[Tensor, LinearOperator]:
    r"""
    Does the forward thing.

    :param x1: The x1 arg
    :param x2: The x2 arg
    :return: The forward stuff.
    """
    # ...

The resulting documentation will include the appropriate types:

Parameters:
  - x1 (torch.Tensor) - The x1 arg
  - x2 (torch.Tensor, optional) - The x2 arg

Return type: torch.Tensor or LinearOperator

Returns: The forward stuff.

This (hopefully) should prevent a lot of duplicate effort on our end.

This PR also refactors the gpytorch.kernels.Kernel and gpytorch.distributions.MultivariateNormal docs to utilize auto-typing.

For example: if the method is...

```python
def forward(self, x1: Tensor, x2: Optional[Tensor]) -> Union[Tensor, LinearOperator]:
    r"""
    Does the forward thing.

    :param x1: The x1 arg
    :param x2: The x2 arg
    :return: The forward stuff.
    """
    # ...
```

The resulting documentation will include the appropriate types:

```
Parameters:

  - x1 (torch.Tensor) - The x1 arg
  - x2 (torch.Tensor, optional) - The x2 arg

Return type: torch.Tensor or LinearOperator

Returns: The forward stuff.
```

This (hopefully) should prevent a lot of duplicate effort on our end.

This commit also refactors the gpytorch.kernels.Kernel and
gpytorch.distributions.MultivariateNormal docs to utilize
auto-typing.
Copy link
Collaborator

@Balandat Balandat left a comment

Choose a reason for hiding this comment

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

can't say I reviewed in detail, but generally lgtm!

@gpleiss gpleiss merged commit c557ddf into master Sep 8, 2022
@gpleiss gpleiss deleted the doc_typehints branch September 8, 2022 03:25
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.

None yet

2 participants