Skip to content

Commit a88da83

Browse files
committed
Add reStructuredText files for class, data, and function documentation
1 parent 12414db commit a88da83

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{ objname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members:
7+
:show-inheritance:
8+
9+
{% block methods %}
10+
{% if methods %}
11+
.. rubric:: Methods
12+
13+
.. autosummary::
14+
:nosignatures:
15+
{% for item in methods %}
16+
~{{ objname }}.{{ item }}
17+
{%- endfor %}
18+
{% endif %}
19+
{% endblock %}
20+
21+
{% block attributes %}
22+
{% if attributes %}
23+
.. rubric:: Attributes
24+
25+
.. autosummary::
26+
:nosignatures:
27+
{% for item in attributes %}
28+
~{{ objname }}.{{ item }}
29+
{%- endfor %}
30+
{% endif %}
31+
{% endblock %}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{ objname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. py:data:: {{ objname }}
6+
7+
{% if objname == "SURFACE_EMG__TENSOR" %}
8+
**Alias of:** ``Annotated[npt.NDArray[np.floating], Is[lambda x: x.ndim == 5]]``
9+
{% elif objname == "INPUT_CURRENT__MATRIX" %}
10+
**Alias of:** ``Annotated[npt.NDArray[np.floating], Is[lambda x: x.ndim == 2]]``
11+
{% elif objname == "SPIKE_TRAIN__MATRIX" %}
12+
**Alias of:** ``Annotated[npt.NDArray[np.bool_], Is[lambda x: x.ndim == 3]]``
13+
{% elif objname == "MUAP_SHAPE__TENSOR" %}
14+
**Alias of:** ``Annotated[npt.NDArray[np.floating], Is[lambda x: x.ndim == 5]]``
15+
{% else %}
16+
**Alias of:** *(see source code)*
17+
{% endif %}
18+
19+
.. rubric:: Type Definition
20+
21+
This type alias is defined using beartype validators::
22+
23+
from typing import Annotated
24+
import numpy.typing as npt
25+
from beartype.vale import Is
26+
27+
{{ objname }} = Annotated[
28+
npt.NDArray[np.floating], # or np.bool_ for boolean arrays
29+
Is[lambda x: x.ndim == N], # where N is the required dimensions
30+
]
31+
32+
.. rubric:: Runtime Type Checking
33+
34+
Use with beartype for automatic validation::
35+
36+
from {{ module }} import {{ objname }}
37+
from beartype import beartype
38+
39+
@beartype
40+
def process_{{ objname.lower().split('_')[0] }}_data(data: {{ objname }}) -> {{ objname }}:
41+
"""Process data with automatic shape validation."""
42+
# beartype automatically validates array dimensions
43+
return data
44+
45+
.. tip::
46+
🐻 **Beartype Integration**: This type uses `beartype <https://github.com/beartype/beartype>`_ validators to ensure arrays have the correct number of dimensions at runtime.
47+
48+
.. note::
49+
📐 **Array Validation**: The `Is[lambda x: x.ndim == N]` validator automatically checks that your NumPy arrays have the expected shape for MyoGen operations.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ objname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autofunction:: {{ objname }}

0 commit comments

Comments
 (0)