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

Lint fixes on benchmarks and examples/*.py#1135

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 3 commits intopython-control:mainfromroryyorke:rory/lint-examples
Mar 8, 2025

Conversation

roryyorke
Copy link
Contributor

@roryyorkeroryyorke commentedMar 2, 2025
edited
Loading

I don't think these are too controversial.

CI failures

I see two failures on CI , but I can't see that these changes caused them:

first, indoctest-linux:https://github.com/roryyorke/python-control/actions/runs/13612156165/job/38050709282

Traceback=========      File "/home/runner/miniconda3/envs/doctest-env/lib/python3.12/site-packages/sphinx/events.py", line 415, in emit        raise ExtensionError(    sphinx.errors.ExtensionError: Handler <function html_collect_pages at 0x7f36a35016c0> for event 'html-collect-pages' threw an exception (exception: module 'sphinx.util' has no attribute 'console')

which seems to besphinx-doc/sphinx#13352.

Then ininstall-examples:https://github.com/roryyorke/python-control/actions/runs/13612156159/job/38050709274

ModuleNotFoundError: No module named 'autoreload'

I'll install jupyterlab in my dev environment and see if I can reproduce this. I can't see that changing *.py files in examples could cause this.

tfvis.py andPwm Pmw

When I rantfvis.py under Python 3.12, I got

AttributeError: module 'collections' has no attribute 'Callable'

inPwm Pmw code.

Callable was moved tocollections.abc in Python 3.10 (October 2021). The hack below lets the script run, but unlesspwm Pmw is updated we should consider retiring this example.

modified   examples/tfvis.py@@ -48,6 +48,9 @@ from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from control.matlab import logspace from numpy import array, conj, polymul, real, size+import collections.abc+collections.Callable = collections.abc.Callable+  def make_poly(facts):     """ Create polynomial from factors """

Warnings in examples

Some examples raise control deprecation warnings, e.g.,genswitch.py usesphase_plot instead ofphase_plane_plot. I started looking into this, but it got a bit involved.

Lint on notebooks

ruff can also run on Jupyter notebooks. Some fixes are obvious:

examples/bode-and-nyquist-plots.ipynb:cell 2:2:17: F401 [*] `scipy` imported but unused  |1 | import numpy as np2 | import scipy as sp  |                 ^^ F4013 | import matplotlib.pyplot as plt4 | import control as ct  |  = help: Remove unused import: `scipy`

but I'm less sure about changing these* imports; they are convenient, and make things more familiar for Matlab users:

examples/pvtol-lqr-nested.ipynb:cell 3:2:1: F403 `from matplotlib.pyplot import *` used; unable to detect undefined names  |1 | from numpy import *             # Grab all of the NumPy functions2 | from matplotlib.pyplot import * # Grab MATLAB plotting functions  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F4033 | from control.matlab import *    # MATLAB-like functions4 | %matplotlib inline  |

@murrayrm
Copy link
Member

The CI errors are also showing up in#1133, so probably something changed on the GitHub Actions end of things. I'll set up a new issue to track that.

@coveralls
Copy link

coveralls commentedMar 2, 2025
edited
Loading

Coverage Status

coverage: 94.745%. remained the same
when pulling5653531 on roryyorke:rory/lint-examples
intoad996f9 on python-control:main.

@roryyorke
Copy link
ContributorAuthor

The CI errors are also showing up in#1133, so probably something changed on the GitHub Actions end of things.

Thanks. I can't reproduce the notebook conversion failure locally. I've attached the output ofmamba list to record versions of everything installed.

I see there's already a bug on Pmw forcollections.Callable, filed in 2020:https://sourceforge.net/p/pmw/bugs/52/

packages.txt

@murrayrmmurrayrm added this to the0.10.2 milestoneMar 3, 2025
@murrayrm
Copy link
Member

Sorry for the delay in reviewing this. All of the changes look good to me.

Some comments on your comments:

tfvis.py and Pmw

Callable was moved to collections.abc in Python 3.10 (October 2021). The hack below lets the script run, but unless pwm Pmw is updated we should consider retiring this example.

I think it would be fine to move this toexamples/legacy. To a large extent the functionality demonstrated in the script is captured insisotool.

Warnings in examples

Some examples raise control deprecation warnings, e.g., genswitch.py uses phase_plot instead of phase_plane_plot. I started looking into this, but it got a bit involved.

Perhaps flag some of these as separate issues? For the specific case ofgenswitch.py (and perhaps others), I likely have new versions that I did for FBS2e (I'm slowly converting all examples and figures to usepython-control).

Lint on notebooks

... I'm less sure about changing these * imports; they are convenient, and make things more familiar for Matlab users ...

It would be nice to run lint on the notebooks. I agree that for MATLAB users, it will be convenient to usefrom control.matlab import * and perhaps we should just flag that one as OK wherever it appears. But I believe that the main control toolbox should always use a prefix (preferablyct for consistency).

@murrayrmmurrayrm merged commit394e1c2 intopython-control:mainMar 8, 2025
40 of 44 checks passed
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.10.2
Development

Successfully merging this pull request may close these issues.

3 participants
@roryyorke@murrayrm@coveralls

[8]ページ先頭

©2009-2025 Movatter.jp