TopoNetX uses the NumPy docstring standard for all functions, classes, and modules. This is required for automated API Reference generation.
Docstring Anatomy
- Summary: A one-line description (under 79 chars) starting with a capital letter and ending with a period. For functions, use the imperative mood (e.g.,
Compute instead of Computes). - Description: A multi-line informative description separated from the summary by a blank line.
- Parameters: A list of arguments including name, type, and shape. Format:
name : type, shape=[...]. For optional parameters, include Optional, default: value. on a new line. - Returns: A list of returned objects with type and description, following the same syntax as Parameters.
- Optional Sections: Use
Raises, See Also, Notes (supports LaTeX via :math:), Examples, and References as needed.
Formatting Rules
- Use built-in Python types (e.g.,
bool instead of boolean). - Use
[ and ] for defining shapes: array-like, shape=[..., dim]. - For multiple string options, use curly braces:
input: str, {"log", "squared"}. - Use
array-like to include lists, while ndarray refers specifically to numpy.ndarray.
def my_method(self, my_param_1, my_param_2="vector"):
r"""Write a one-line summary for the method.
Write a description of the method, including "big O"
(:math:`O\left(g\left(n\right)\right)`) complexities.
Parameters
----------
my_param_1 : array-like, shape=[..., dim]
Write a short description of parameter my_param_1.
my_param_2 : str, {"vector", "matrix"}
Write a short description of parameter my_param_2.
Optional, default: "vector".
Returns
-------
my_result : array-like, shape=[..., dim, dim]
Write a short description of the result returned by the method.
Notes
-----
If relevant, provide equations with (:math:)
describing computations performed in the method.
Examples
--------
Provide code snippets showing how the method is used.
Reference
---------
If relevant, provide a reference with associated pdf or
wikipedia page.
"""
pass