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

Improved type hints in documentation #662

Merged

Conversation

JonathanWenger
Copy link
Contributor

@JonathanWenger JonathanWenger commented Mar 18, 2022

In a Nutshell

Type aliases are not properly shown in the documentation and usually expanded completely. This can make the documentation very hard to read and the typing information not very useful.

Screenshot from 2022-03-18 22-23-39

This PR uses Sphinx native functionality to display type hints instead.

Detailed Description

  • Added probnum.typing to the API Documentation
  • Removed plugin sphinx-autodoc-typehints
  • Added Sphinx extension autodoc
  • Removed colons in some commonly used classes

If a type alias still is expanded completely in the documentation the following should be added to the file:

from __future__ import annotations

Other

Note that now the new standard for documenting Parameters is to not use a colon (:).

Parameters
---------------
arg :
    Argument, where the docs may show no type hint.
betterarg
    Argument which will be documented with a type hint.

Otherwise autodoc may interpret the type of the parameter as empty.

@JonathanWenger JonathanWenger added the documentation Improvements or additions to documentation label Mar 18, 2022
@JonathanWenger JonathanWenger self-assigned this Mar 18, 2022
@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #662 (e5de312) into main (0f19c11) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #662      +/-   ##
==========================================
+ Coverage   90.23%   90.26%   +0.03%     
==========================================
  Files         192      192              
  Lines        7238     7262      +24     
  Branches     1153     1153              
==========================================
+ Hits         6531     6555      +24     
  Misses        462      462              
  Partials      245      245              
Impacted Files Coverage Δ
src/probnum/linops/_linear_operator.py 86.15% <ø> (ø)
...bnum/randprocs/kernels/_exponentiated_quadratic.py 100.00% <ø> (ø)
src/probnum/randprocs/kernels/_kernel.py 92.55% <ø> (ø)
src/probnum/randprocs/kernels/_matern.py 94.11% <ø> (ø)
src/probnum/randprocs/kernels/_polynomial.py 100.00% <ø> (ø)
src/probnum/randprocs/kernels/_product_matern.py 100.00% <ø> (ø)
...c/probnum/randprocs/kernels/_rational_quadratic.py 100.00% <ø> (ø)
src/probnum/randprocs/kernels/_white_noise.py 88.23% <ø> (ø)
src/probnum/_function.py 95.23% <100.00%> (+0.11%) ⬆️
src/probnum/diffeq/_odesolver.py 100.00% <100.00%> (ø)
... and 25 more

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@JonathanWenger
Copy link
Contributor Author

Note that currently in some classes type hints for Parameters are not shown. This seems to be a bug in automodapi. As this might influence the entire way we currently generate the documentation (i.e. switch to a different plugin for api generation) I would prefer to consider this as out of scope for this PR.

Copy link
Collaborator

@marvinpfoertner marvinpfoertner left a comment

Choose a reason for hiding this comment

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

Minor stuff, otherwise perfect 👍🏻

docs/source/conf.py Outdated Show resolved Hide resolved
src/probnum/randvars/_constant.py Outdated Show resolved Hide resolved
JonathanWenger and others added 2 commits March 21, 2022 07:46
Co-authored-by: Marvin Pförtner <marvin.pfoertner@icloud.com>
@JonathanWenger JonathanWenger added this to In progress in ProbNum Development via automation Mar 22, 2022
Copy link
Collaborator

@marvinpfoertner marvinpfoertner left a comment

Choose a reason for hiding this comment

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

Just a typo left :)

src/probnum/randprocs/_random_process.py Outdated Show resolved Hide resolved
ProbNum Development automation moved this from In progress to Review in progress Mar 23, 2022
Co-authored-by: Marvin Pförtner <marvin.pfoertner@icloud.com>
@JonathanWenger JonathanWenger merged commit d24b6b0 into probabilistic-numerics:main Mar 23, 2022
ProbNum Development automation moved this from Review in progress to Done Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants