Skip to content

Commit aad3c75

Browse files
committed
add check for empty section + fix correlation() docstring
1 parent 724adc0 commit aad3c75

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

control/stochsys.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ def correlation(T, X, Y=None, squeeze=True):
683683
684684
Returns
685685
-------
686+
tau : array
687+
Array of time offsets.
688+
Rtau : array
689+
Correlation for each offset tau.
686690
687691
"""
688692
T = np.atleast_1d(T)

control/tests/docstrings_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,14 @@ def _check_numpydoc_style(obj, doc):
615615
pass
616616
elif inspect.isfunction(obj):
617617
# Specialized checks for functions
618-
def _check_param(param, empty_ok=False, noname_ok=False):
618+
def _check_param(param, empty_ok=False, noname_ok=False, section="??"):
619619
param_desc = "\n".join(param.desc)
620620
param_name = f"{name} '{param.name}'"
621621

622+
# Check for empty section
623+
if param.name == "" and param.type == '':
624+
_fail(f"Empty {section} section in {name}")
625+
622626
# Make sure we have a name and description
623627
if param.name == "" and not noname_ok:
624628
_fail(f"{param_name} has improperly formatted parameter")
@@ -636,11 +640,13 @@ def _check_param(param, empty_ok=False, noname_ok=False):
636640
_warn(f"{param_name} description starts with lower case letter")
637641

638642
for param in doc["Parameters"] + doc["Other Parameters"]:
639-
_check_param(param)
643+
_check_param(param, section="Parameters")
640644
for param in doc["Returns"]:
641-
_check_param(param, empty_ok=True, noname_ok=True)
645+
_check_param(
646+
param, empty_ok=True, noname_ok=True, section="Returns")
642647
for param in doc["Yields"]:
643-
_check_param(param, empty_ok=True, noname_ok=True)
648+
_check_param(
649+
param, empty_ok=True, noname_ok=True, section="Yields")
644650
else:
645651
raise TypeError("unknown object type for {obj}")
646652

0 commit comments

Comments
 (0)