Skip to content

Type Hints for Analysis Classes #3463

@PicoCentauri

Description

@PicoCentauri

Is your feature request related to a problem?

With the first version of the CLI released, we now would like to support more Analysis classes.
This is especially limited to classes taking lists as parameters as the InterRDF_s

class InterRDF_s(AnalysisBase):
r"""Site-specific intermolecular pair distribution function
Arguments
---------
u : Universe
a Universe that contains atoms in `ags`
ags : list
a list of pairs of :class:`~MDAnalysis.core.groups.AtomGroup`
instances
nbins : int (optional)
Number of bins in the histogram
range : tuple or list (optional)
The size of the RDF
density : bool (optional)
``False``: calculate :math:`g_{ab}(r)`; ``True``: calculate
the true :ref:`single particle density<equation-nab>`
:math:`n_{ab}(r)`.

where ags is a list of AtomGroups. For building the CLI we have to know the variable type. For example, what is the type of the list elements. The current implementation does not allow this. To overcome this issue we could introduce type hints as they were discussed in issues previously.

Describe the solution you'd like

Adding type hints to the Analysis classes. Type hints can be easily extracted using the typing module

typing.get_type_hints(InterRDF_s.__init__)

Describe alternatives you've considered

Be more precise in the docstring about parameter types. Similar to type hints but only (or maybe additionally) in the docstring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions