-
Notifications
You must be signed in to change notification settings - Fork 438
Documentation updates and testing #1038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation updates and testing #1038
Conversation
c9a07c1
to
4ef9dd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to finish review tomorrow.
control/ctrlplot.py
Outdated
@@ -220,6 +221,10 @@ def suptitle( | |||
def get_plot_axes(line_array): | |||
"""Get a list of axes from an array of lines. | |||
|
|||
.. deprecated:: 0.10.1 | |||
This function will be removed in a future version of python-control. | |||
Use `cplt.axes` to obtain axes for a control plot `cplt`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use `cplt.axes` to obtain axes for a control plot `cplt`. | |
Use `cplt.axes` to obtain axes for an instance of :class:`ControlPlot`. |
Even though get_plot_axes()
is defined in the same module (ctrlplot
) as ControlPlot
, it is available at the top of the package as control.get_plot_axes()
, so a user may not realize that cplt
abbreviates the new class ControlPlot
. E.g., observe how get_plot_axes()
is shown at https://python-control.readthedocs.io/en/0.10.0/generated/control.get_plot_axes.html.
Therefore, I recommend to be explicit here when referring to the class ControlPlot
.
control/ctrlplot.py
Outdated
@@ -268,6 +274,9 @@ def pole_zero_subplots( | |||
Scaling to apply to the subplots. | |||
fig : :class:`matplotlib.figure.Figure` | |||
Figure to use for creating subplots. | |||
rcParams : dict | |||
Override the default parameters used for generating plots. | |||
Default is set up config.default['freqplot.rcParams']. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default is set up config.default['freqplot.rcParams']. | |
Default is set up config.default['ctrlplot.rcParams']. |
Frequency label (defaults to "rad/sec" or "Hertz") | ||
freq_label, magnitude_label, phase_label : str, optional | ||
Labels to use for the frequency, magnitude, and phase axes. | ||
Defaults are set by `config.defaults['freqplot.<keyword>']`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that descriptions of these parameter are combined, but in this case, magnitude_label
and phase_label
should be deleted below.
control/freqplot.py
Outdated
show_legend : bool, optional | ||
Force legend to be shown if ``True`` or hidden if ``False``. If | ||
``None``, then show legend when there is more than one line on an | ||
axis or ``legend_loc`` or ``legend_map`` has been specified. | ||
title : str, optional | ||
Set the title of the plot. Defaults to plot type and system name(s). | ||
title_frame : str, optional | ||
Set the frame of reference used to center the plot title. If set to | ||
'axes' (default), the horizontal position of the title will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'axes' (default), the horizontal position of the title will | |
'axes' (default), the horizontal position of the title will be |
control/freqplot.py
Outdated
title_frame : str, optional | ||
Set the frame of reference used to center the plot title. If set to | ||
'axes' (default), the horizontal position of the title will | ||
centered relative to the axes. If set to `figure`, it will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
centered relative to the axes. If set to `figure`, it will be | |
centered relative to the axes. If set to 'figure', it will be |
To be consistent with 'axes' and other strings in these parameter descriptions, this should be 'figure' rather than `figure`.
control/freqplot.py
Outdated
title_frame : str, optional | ||
Set the frame of reference used to center the plot title. If set to | ||
'axes' (default), the horizontal position of the title will | ||
centered relative to the axes. If set to `figure`, it will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
centered relative to the axes. If set to `figure`, it will be | |
centered relative to the axes. If set to 'figure', it will be |
To be consistent with 'axes' and other strings in these parameter descriptions, this should be 'figure' rather than figure
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work on the docstrings checker. It seems useful enough to be offered to the numpydoc repository or made into a ruff rule.
I added several more small comments. After considering those, this is ready to merge.
control/statesp.py
Outdated
inputs : int, list of str, or None | ||
Description of the system inputs. This can be given as an integer | ||
states : int, list of str, or None | ||
Description of the system states. Same format as `inputs`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description of the system states. Same format as `inputs`. | |
Description of the system states. Same format as `outputs`. |
For inputs
, we have "Same format as outputs
." Best to just point from here to outputs
(instead of inputs
, which in turn points to outputs
).
control/phaseplot.py
Outdated
@@ -985,6 +1013,9 @@ def phase_plot(odefun, X=None, Y=None, scale=1, X0=None, T=None, | |||
|
|||
"""(legacy) Phase plot for 2D dynamical systems. | |||
|
|||
.. deprecated:: 0.10.1 | |||
This function is deprecated; use `phase_plane_plot` instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is deprecated; use `phase_plane_plot` instead. | |
This function is deprecated; use :func:`phase_plane_plot` instead. |
Else, Sphinx/numpydoc will not create a link.
@@ -1243,14 +1274,18 @@ def phase_plot(odefun, X=None, Y=None, scale=1, X0=None, T=None, | |||
def box_grid(xlimp, ylimp): | |||
"""box_grid generate list of points on edge of box | |||
|
|||
.. deprecated:: 0.10.0 | |||
Use :func:`phaseplot.boxgrid` instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that neither boxgrid()
nor box_grid()
appear in the generated user's manual, so this :func:
link is not used anywhere that I observed.
control/tests/docstrings_test.py
Outdated
if f"*{argname}" not in docstring and verbose: | ||
print(f" {name} has positional arguments; " | ||
"check manually") | ||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if f"*{argname}" not in docstring and verbose: | |
print(f" {name} has positional arguments; " | |
"check manually") | |
warnings.warn( | |
if f"*{argname}" not in docstring: | |
if verbose: | |
print(f" {name} has positional arguments; " | |
"check manually") | |
warnings.warn( |
This warning message should be sent independently of verbose
.
This PR provides updated docstrings for a large number of functions that had undocumented arguments, along with a unit test that checks to make sure that positional arguments and keyword arguments are appropriately documented. The unit test (
docstring_test.py
) checks for the following:FutureWarning
.Implementing this unit test picked up ~30 undocumented variables that are now documented, as well as triggering a few changes in argument processing and some argument hiding (for internal arguments that the user should never call, which now should start with an underscore).
This PR contains no changes in functionality, just docstring updates and small code changes for consistency (eg,
DeprecationWarning
[which is ignored/hidden by default] →FutureWarning
[which generates a user-visible warning]).