Skip to content

Fix CI test and doctest failures with updated NumPy, SciPy, and Matplotlib - #1243

Merged
slivingston merged 6 commits into
python-control:mainfrom
murrayrm:update_tests-08Aug2026
Aug 9, 2026
Merged

Fix CI test and doctest failures with updated NumPy, SciPy, and Matplotlib#1243
slivingston merged 6 commits into
python-control:mainfrom
murrayrm:update_tests-08Aug2026

Conversation

@murrayrm

@murrayrm murrayrm commented Aug 8, 2026

Copy link
Copy Markdown
Member

A collection of small, independent fixes for test and doctest failures
appearing in CI. No functional changes to the library API. Open PRs
with failing CI tests should rebase onto main once this is merged.

NumPy: unsupported shape assignment

ndarray.shape assignment is no longer supported in these contexts;
replaced with reshape().

  • control/descfcn.pydescribing_function()
  • control/statesp.pyStateSpace.__init__(), static-system reshaping

NumPy: complex-to-real casts

Discard the (numerically zero) imaginary parts explicitly rather than
letting NumPy warn on the implicit cast.

  • control/modelsimp.pyhankel_singular_values() takes sqrt(w.real),
    since Wo @ Wc is symmetric positive semidefinite in exact arithmetic
  • control/phaseplot.pyseparatrices() uses the real part of the
    eigenvector, avoiding complex initial conditions

Matplotlib: warning no longer emitted

  • control/tests/ctrlplot_test.py — drop the pytest.warns(UserWarning, match="Tight layout not applied") check in
    test_pole_zero_subplots(), which no longer fires

Platform-dependent numerics

  • control/tests/nyquist_test.pytest_nyquist_indent_near_imaginary_axis()
    now constructs the system with ct.zpk(), placing the poles near the
    imaginary axis explicitly instead of relying on the roots of a
    polynomial, which gave inconsistent indent signs
  • control/lti.py, doc/intro.rstbandwidth() doctests use
    # doctest: +ELLIPSIS with ~14 significant digits. The value comes from
    a scipy.optimize.root_scalar bisection, so the last digit or two of
    the repr varies across SciPy/BLAS builds; the full-precision literals
    passed locally but failed on GitHub runners. +ELLIPSIS keeps the
    examples verified, unlike the +SKIP used elsewhere for
    platform-dependent output, and trim_doctest_flags (on by default)
    strips the flag comment from the rendered HTML.

Testing

make doctest in doc/: 728 tests, 0 failures
(Python 3.14.6, NumPy 2.5.1, SciPy 1.18.0).

AI disclosure

Per the AI policy referenced in README.rst: the bandwidth() doctest
change was written with assistance from Claude Code. I have reviewed it
and take responsibility for its content.

murrayrm and others added 6 commits August 8, 2026 10:09
bandwidth() gets its value from a scipy.optimize.root_scalar bisection,
so the last digit or two of the repr differs across scipy/BLAS builds.
The full-precision literals matched locally but failed on GitHub.

Truncate to ~14 significant digits with # doctest: +ELLIPSIS.  This
keeps the examples verified (unlike +SKIP, used elsewhere in the repo
for platform-dependent output), and trim_doctest_flags (on by default)
strips the flag comment from the rendered HTML.

Also applied to the G1*G2 example, which has the same origin and had
not failed yet.

Verified with "make doctest" in doc/: 728 tests, 0 failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.74% (+0.2%) from 94.579% — murrayrm:update_tests-08Aug2026 into python-control:main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants