qiskit-community / qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
https://qiskit-community.github.io/qiskit-nature/
Apache License 2.0
291 stars 197 forks source link

Inconsistent handling of class attributes in docs and missing attribute descriptions #1269

Open grossardt opened 8 months ago

grossardt commented 8 months ago

I noticed that class attributes are not documented very well, take e.g. FermionicOp:

I am not completely sure if this is a bug or somehow intentional. Also not sure if it can just be fixed via the Sphinx configuration, but my feeling is that the docstrings themselves should be amended?

Comparing with the qiskit docs, attributes typically seem to be defined directly after the class docstring with a type declaration and followed by their docstring (and mostly without assigning a value), e.g. for the FermionicOp we would have something like:

class FermionicOp(SparseLabelOp):
    r"""N-mode Fermionic operator.
    ...
    """

    num_spin_orbitals: int
    """The number of spin orbitals"""

    atol: float
    """Absolute numerical tolerance used by the class methods"""
mrossinek commented 8 months ago

Thanks for pointing this out! Indeed, the handling of @property attributes and publicly directly accessible attributes is a bit inconsistent, especially when it comes to how they are displayed in the docs. In the past, we used to only have @property attributes but over the past few releases we have started using pubic attributes directly, if the @property getter/setter methods are trivial.

What you see now, is likely also different to before, because the Sphinx theme which we use for our docs has been changed significantly. I will bring this issue to the team's attention who is working on the theme because I believe they would be interested in improving this :+1: