Skip to content
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

Conda forge mkl #6

Closed
wants to merge 8 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/scripts/numpy-info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from numpy.core._multiarray_umath import (
__cpu_features__, __cpu_baseline__, __cpu_dispatch__)

features_found, features_not_found = [], []
for feature in __cpu_dispatch__:
if __cpu_features__[feature]:
features_found.append(feature)
else:
features_not_found.append(feature)

print("Supported SIMD extensions in this NumPy install:")
print(" baseline = %s" % (','.join(__cpu_baseline__)))
print(" found = %s" % (','.join(features_found)))
print(" not found = %s" % (','.join(features_not_found)))
9 changes: 7 additions & 2 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: [3.6, 3.9]
python-version: [3.9]
slycot: ["", "conda"]
array-and-matrix: [0]
include:
Expand All @@ -36,7 +36,9 @@ jobs:
pip install coveralls

# Install python-control dependencies
conda install numpy matplotlib scipy
conda install -c conda-forge 'libblas=*=*mkl' mkl
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
conda install -c conda-forge numpy matplotlib scipy
if [[ '${{matrix.slycot}}' == 'conda' ]]; then
conda install -c conda-forge slycot
fi
Expand All @@ -49,6 +51,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 .github/scripts/numpy-info.py

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