Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature enable doctest#868

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
murrayrm merged 10 commits intopython-control:mainfromhenklaak:feature_enable_doctest
Mar 27, 2023
Merged

Feature enable doctest#868

murrayrm merged 10 commits intopython-control:mainfromhenklaak:feature_enable_doctest
Mar 27, 2023

Conversation

henklaak
Copy link
Contributor

@henklaakhenklaak commentedFeb 21, 2023
edited
Loading

Hi, PR to enable doctest


Introducing a new doc/Makefile target: 'doctest'
Run doctests manually with:

cd docmake html doctest

Introducing a new CI workflow: 'doctest'
This will run doctest on ubuntu-latest, python 3.11 with full package dependencies.
This one configuration is sufficient and required for running all doctests.


Reworked and added many docstrings.

@coveralls
Copy link

coveralls commentedFeb 21, 2023
edited
Loading

Coverage Status

Coverage: 94.866% (+0.02%) from 94.841% when pullingdf38286 on henklaak:feature_enable_doctest into26c44e1 on python-control:main.

@henklaak
Copy link
ContributorAuthor

henklaak commentedFeb 21, 2023
edited
Loading

Oh, one possibly contentious thingy.
The Doctest workflow generates a test artifactdoctest-output which contains the test results.
I thought it might come in handy at times.

Copy link
Member

@murrayrmmurrayrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great contribution to the library. I had a lot of small comments as I read through. A few more substantive ones:

  • I didn't understand the reason for changingclasses.pdf toclasses.png. The former should display with much better resolution.
  • I don't think we need to include check_{cvxopt,pandas,slycot} in the sphinx docs nor include examples for them. They are essentially internal functions.
  • In some places the outputs that are shown are not very informative (eg, the dimensions of a system rather than the system inpade).
  • If we are going to update docstrings, we should update the examples to match the more modern usage (eg, usingss([[1, 2], [3, 4]], [[5], [6]], [[7, 8]], [[9]]) instead of the MATLAB-esquess("1 2; 3 4", "5; 6", "7 8", "9").

Comment on lines 49 to 50
matrix([[1.],
[0.]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't this bearray instead ofmatrix? And why skip the doctest?

This same issue come up multiple times below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I fixed these in98fdb35. In a few cases I had to useround() to get rid of problems between platforms (see1d1c289), and for one or two cases I had to skip the test because0. would become-0. on some platforms, even after rounding.

Copy link
ContributorAuthor

@henklaakhenklaakMar 27, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Shouldn't this bearray instead ofmatrix? And why skip the doctest?

This same issue come up multiple times below.

Doctest has an existing flaw/feature, in that it doesn't do float comparisons. Down below, it's just string compare.
When system precision affects the result, small tolerances can lead to test failure.
I'll have a hard look at it again, because it annoys me no end.
(Might even have to submit a patch to the Doctest project ;-)

All the round() and other tricks to get around it are just confusing for users who look at the examples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good point. I have removed this and will go through an +SKIP any that fail.

Comment on lines 44 to 45
>>> G = tf([1],[1, 3, 2])
>>> Gs = tf2ss(G)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You could simplify this to beG = tf2ss([1], [1, 3, 2]).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I fixed all of these in98fdb35.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I tried to keep the examples very much step-by-step, so users can understand things more easily.
I'm perfectly fine with anything that teaches the user better habits.

Comment on lines 80 to 83
>>> # do some customized freqplotting
>>> reset_defaults()
>>> defaults['freqplot.number_of_samples']
1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this belong here? It is repeated inreset_defaults, below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I got rid of line 82, but line 81 is required so that doctest leaves the state unchanged for the next test in this module.

>>> unwrap(theta, period=2 * np.pi)
[5.74, 5.97, 6.19, 6.413185307179586, 6.633185307179586, 6.8531853071795865]
>>> from control import unwrap
>>> from pprint import pprint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this used?


Examples
--------
>>> from control import issys, tf, InputOutputSystem, LinearIOSystem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LinearIOSystem is not used andInputOutputSystem can probably be replaced with something else (see below).

doc/Makefile Outdated
classes.pdf: classes.fig;fig2dev -Lpdf $< $@
FIGS = classes.png
classes.png: classes.fig
fig2dev -Lpng $< $@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why change from pdf to png? The pdf will render much more nicely? Also, if there is a reason to keep the PNG file, then we should not add it to the repository (it is created by the Makefile).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I reverted this change.

@@ -24,7 +24,7 @@ The following figure illustrates the relationship between the classes and
some of the functions that can be used to convert objects from one class to
another:

.. image:: classes.pdf
.. image:: classes.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggest leaving as PDF unless there is a reason not to.

@@ -172,6 +172,7 @@ Utility functions and conversions
augw
bdschur
canonical_form
cvxopt_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not really intended as a user function; we should probably not include it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I got rid of the*_check entries.

@@ -182,9 +183,13 @@ Utility functions and conversions
modal_form
observable_form
pade
pandas_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not really intended as a user function; we should probably not include it here.

reachable_form
reset_defaults
sample_system
set_defaults
similarity_transform
slycot_check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not really intended as a user function; we should probably not include it here.

@murrayrm
Copy link
Member

@henklaak I went ahead and made updates to resolve most of my comments. In addition to the addressing substantive comments in my overall review, I also set up doctests to use thect prefix for all python-control functions, which matches the way NumPy docstring examples are done. The import command that sets this up is indoc/conf.py (it also imports numpy asnp).

I'll leave this PR sitting for a few days in case you want to make comments, but I think it is ready to be merged. Thanks again for this very nice contribution!

@murrayrmmurrayrm merged commit2c5c2f0 intopython-control:mainMar 27, 2023
@murrayrmmurrayrm added this to the0.9.4 milestoneMar 27, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@murrayrmmurrayrmmurrayrm approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.9.4
Development

Successfully merging this pull request may close these issues.

3 participants
@henklaak@coveralls@murrayrm

[8]ページ先頭

©2009-2025 Movatter.jp