Skip to content

Another take at #664 #665

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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
# Use xvfb-run instead of pytest-xvfb to get proper mpl backend
# Use coverage instead of pytest-cov to get .coverage file
# See https://github.com/python-control/python-control/pull/504

python3 -c 'import numpy; numpy.show_config()'

xvfb-run --auto-servernum coverage run -m pytest control/tests

- name: Coveralls parallel
Expand Down
18 changes: 10 additions & 8 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,8 @@ def horner(self, x, warn_infinite=True):
"""
# Make sure the argument is a 1D array of complex numbers
x_arr = np.atleast_1d(x).astype(complex, copy=False)
if len(x_arr.shape) > 1:
raise ValueError("input list must be 1D")

# return fast on systems with 0 or 1 state
if not config.defaults['statesp.use_numpy_matrix']:
Expand All @@ -908,21 +910,21 @@ def horner(self, x, warn_infinite=True):
# Fall back because either Slycot unavailable or cannot handle
# certain cases.

# Make sure that we are operating on a simple list
if len(x_arr.shape) > 1:
raise ValueError("input list must be 1D")

# Preallocate
out = empty((self.noutputs, self.ninputs, len(x_arr)),
dtype=complex)

# TODO: can this be vectorized?
for idx, x_idx in enumerate(x_arr):
try:
out[:, :, idx] = np.dot(
self.C,
solve(x_idx * eye(self.nstates) - self.A, self.B)) \
+ self.D
xI_A = x_idx * eye(self.nstates) - self.A
xI_A_inv = solve(xI_A, self.B)
# gh-664: xI_A did not raise singular matrix error,
print(f"DEBUG np.linalg.solve(\n,"
f"{xI_A}\n"
f"{self.B} = \n"
f"{xI_A_inv}")
out[:, :, idx] = np.dot(self.C, xI_A_inv) + self.D
except LinAlgError:
# Issue a warning messsage, for consistency with xferfcn
if warn_infinite:
Expand Down