Skip to content

Commit fdb2d4a

Browse files
author
Mark
committed
Attempt to setup cvxopt similar to slycot.
1 parent 147a24e commit fdb2d4a

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/python-package-conda.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
python-version: [3.7, 3.9]
1414
slycot: ["", "conda"]
1515
pandas: [""]
16+
cvxopt: ["conda"]
1617
array-and-matrix: [0]
1718
include:
1819
- python-version: 3.9
@@ -46,6 +47,9 @@ jobs:
4647
if [[ '${{matrix.pandas}}' == 'conda' ]]; then
4748
conda install -c conda-forge pandas
4849
fi
50+
if [[ '${{matrix.cvxopt}}' == 'conda' ]]; then
51+
conda install -c conda-forge cvxopt
52+
fi
4953
5054
- name: Test with pytest
5155
env:

control/exception.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,15 @@ def pandas_check():
8484
except:
8585
pandas_installed = False
8686
return pandas_installed
87+
88+
# Utility function to see if cvxopt is installed
89+
cvxopt_installed = None
90+
def cvxopt_check():
91+
global cvxopt_installed
92+
if cvxopt_installed is None:
93+
try:
94+
import cvxopt
95+
cvxopt_installed = True
96+
except:
97+
cvxopt_installed = False
98+
return cvxopt_installed

control/tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# pytest.param(marks=)
1919
slycotonly = pytest.mark.skipif(not control.exception.slycot_check(),
2020
reason="slycot not installed")
21+
cvxoptonly = pytest.mark.skipif(not control.exception.cvxopt_check(),
22+
reason="cvxopt not installed")
2123
noscipy0 = pytest.mark.skipif(StrictVersion(sp.__version__) < "1.0",
2224
reason="requires SciPy 1.0 or greater")
2325
nopython2 = pytest.mark.skipif(sys.version_info < (3, 0),

control/tests/passivity_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Date: May 30, 2022
44
'''
55

6-
import pytest
76
import numpy
87
from control import ss, passivity
98
from sympy import Matrix
9+
from control.tests.conftest import cvxoptonly
1010

11-
11+
@cvxoptonly
1212
def test_is_passive():
1313
A = numpy.array([[0, 1], [-2, -2]])
1414
B = numpy.array([[0], [1]])

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
'matplotlib'],
4444
extras_require={
4545
'test': ['pytest', 'pytest-timeout'],
46-
'slycot': [ 'slycot>=0.4.0' ]
46+
'slycot': [ 'slycot>=0.4.0' ],
47+
'cvxopt': [ 'cvxopt>=1.2.0' ]
4748
}
4849
)

0 commit comments

Comments
 (0)