Skip to content

Attribute types missing in documentation #304

@leahaeusel

Description

@leahaeusel

Description of the Issue:

When I added type annotations to the distributions (#221) and to the parameters (#240), I removed the types of the class attributes, because modern IDEs automatically resolve the type when you hover over an attribute of interest.

What I didn't take into account is that Sphinx apparently isn't able to do that, and the class attribute types are now missing in the documentation:

Image

Proposed Solution:

The attribute types need to be added again in the following way:

class Normal(Continuous):
    """Normal distribution.

    Attributes:
        low_chol: Lower-triangular Cholesky factor of covariance matrix.
        precision: Precision matrix corresponding to covariance matrix.
        logpdf_const: Constant for evaluation of log-PDF.
    """

    low_chol: np.ndarray
    precision: np.ndarray
    logpdf_const: np.float64

which results in the following documentation:

Image

In contrast to our previous type annotation within the docstring, this approach comes with the advantage that mypy will automatically check whether the attribute types conform to the usage of the attribute in the code.

Action Items:

  • reintroduce class attribute types in the way proposed above
  • check if there is a way to enforce type annotations for class attributes such that the pipeline fails when they are missing (as they are now)

Related Issues:

#74

Interested Parties:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: ready to implementSolution for this issue is available but implementation is missingtopic: documentationIssue/PR related to the documentationtype: usabilityIssue/PR to improve usability

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions