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

Commit45d677f

Browse files
committed
extend fixture usage to matarrayin and matarrayout, pytestify statefbk_test.py
this replaces the funcitionality of previously dropped statefbk_matrix_test.pyto test that the functions work with (dperecated) matrix input
1 parent89118fe commit45d677f

File tree

4 files changed

+165
-144
lines changed

4 files changed

+165
-144
lines changed

‎control/tests/conftest.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@
2020

2121

2222
@pytest.fixture(scope="session",autouse=test_ndarray,
23-
params=["array","matrix"])
24-
defuse_numpy_ndarray_and_matrix(request):
25-
"""Switch the config to use np.ndarrayor np.matrix"""
23+
params=["arrayout","matrixout"])
24+
defmatarrayout(request):
25+
"""Switch the config to use np.ndarrayand np.matrix as returns"""
2626
restore=control.config.defaults['statesp.use_numpy_matrix']
27-
control.use_numpy_matrix(request.param=="matrix",warn=False)
27+
control.use_numpy_matrix(request.param=="matrixout",warn=False)
2828
yield
2929
control.use_numpy_matrix(restore,warn=False)
3030

3131

32-
defis_matrix_or_array(obj):
32+
defismatarrayout(obj):
3333
"""Test if the returned object has the correct type as configured"""
3434
use_matrix=control.config.defaults['statesp.use_numpy_matrix']
3535
returnisinstance(obj,np.matrixifuse_matrixelsenp.ndarray)
3636

3737

38+
defasmatarrayout(obj):
39+
"""Return a object according to the configured default"""
40+
use_matrix=control.config.defaults['statesp.use_numpy_matrix']
41+
matarray=np.asmatrixifuse_matrixelsenp.asarray
42+
returnmatarray(obj)
43+
44+
3845
@contextmanager
3946
defcheck_deprecated_matrix():
4047
"""Check that a call produces a deprecation warning because of np.matrix"""
@@ -49,6 +56,14 @@ def check_deprecated_matrix():
4956
yield
5057

5158

59+
@pytest.fixture(scope="session",
60+
params=[np.array,np.matrix]iftest_ndarrayelse [np.array],
61+
ids=["arrayin","matrixin"]iftest_ndarrayelse ["arrayin"])
62+
defmatarrayin(request):
63+
"""Use array and matrix to construct input data in tests"""
64+
returnrequest.param
65+
66+
5267
@pytest.fixture(scope="function")
5368
defeditsdefaults():
5469
"""Make sure any changes to the defaults only last during a test"""

‎control/tests/modelsimp_array_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestModelsimp:
1616
"""Test model reduction functions"""
1717

1818
@slycotonly
19-
deftestHSVD(self,use_numpy_ndarray_and_matrix):
19+
deftestHSVD(self,matarrayout):
2020
A=np.array([[1.,-2.], [3.,-4.]])
2121
B=np.array([[5.], [7.]])
2222
C=np.array([[6.,8.]])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp