Skip to content

Commit f45d61e

Browse files
committed
update tests to avoid NumPy matrix deprecation
1 parent f95dc54 commit f45d61e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

control/tests/iosys_test.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,31 +1250,34 @@ def test_lineariosys_statespace(self, tsys):
12501250

12511251
@pytest.mark.parametrize(
12521252
"Pout, Pin, C, op, PCout, PCin", [
1253-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__mul__, 2, 2),
1253+
(2, 2, 'rss', ct.LinearIOSystem.__mul__, 2, 2),
12541254
(2, 2, 2, ct.LinearIOSystem.__mul__, 2, 2),
12551255
(2, 3, 2, ct.LinearIOSystem.__mul__, 2, 3),
12561256
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__mul__, 2, 2),
1257-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__rmul__, 2, 2),
1257+
(2, 2, 'rss', ct.LinearIOSystem.__rmul__, 2, 2),
12581258
(2, 2, 2, ct.LinearIOSystem.__rmul__, 2, 2),
12591259
(2, 3, 2, ct.LinearIOSystem.__rmul__, 2, 3),
12601260
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__rmul__, 2, 2),
1261-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__add__, 2, 2),
1261+
(2, 2, 'rss', ct.LinearIOSystem.__add__, 2, 2),
12621262
(2, 2, 2, ct.LinearIOSystem.__add__, 2, 2),
12631263
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__add__, 2, 2),
1264-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__radd__, 2, 2),
1264+
(2, 2, 'rss', ct.LinearIOSystem.__radd__, 2, 2),
12651265
(2, 2, 2, ct.LinearIOSystem.__radd__, 2, 2),
12661266
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__radd__, 2, 2),
1267-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__sub__, 2, 2),
1267+
(2, 2, 'rss', ct.LinearIOSystem.__sub__, 2, 2),
12681268
(2, 2, 2, ct.LinearIOSystem.__sub__, 2, 2),
12691269
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__sub__, 2, 2),
1270-
(2, 2, ct.rss(2, 2, 2), ct.LinearIOSystem.__rsub__, 2, 2),
1270+
(2, 2, 'rss', ct.LinearIOSystem.__rsub__, 2, 2),
12711271
(2, 2, 2, ct.LinearIOSystem.__rsub__, 2, 2),
12721272
(2, 2, np.random.rand(2, 2), ct.LinearIOSystem.__rsub__, 2, 2),
12731273
12741274
])
12751275
def test_operand_conversion(self, Pout, Pin, C, op, PCout, PCin):
12761276
P = ct.LinearIOSystem(
12771277
ct.rss(2, Pout, Pin, strictly_proper=True), name='P')
1278+
if isinstance(C, str) and C == 'rss':
1279+
# Need to generate inside class to avoid matrix deprecation error
1280+
C = ct.rss(2, 2, 2)
12781281
PC = op(P, C)
12791282
assert isinstance(PC, ct.LinearIOSystem)
12801283
assert isinstance(PC, ct.StateSpace)
@@ -1283,20 +1286,24 @@ def test_operand_conversion(self, Pout, Pin, C, op, PCout, PCin):
12831286

12841287
@pytest.mark.parametrize(
12851288
"Pout, Pin, C, op", [
1286-
(2, 2, ct.rss(2, 3, 2), ct.LinearIOSystem.__mul__),
1287-
(2, 2, ct.rss(2, 2, 3), ct.LinearIOSystem.__rmul__),
1288-
(2, 2, ct.rss(2, 3, 2), ct.LinearIOSystem.__add__),
1289-
(2, 2, ct.rss(2, 2, 3), ct.LinearIOSystem.__radd__),
1289+
(2, 2, 'rss32', ct.LinearIOSystem.__mul__),
1290+
(2, 2, 'rss23', ct.LinearIOSystem.__rmul__),
1291+
(2, 2, 'rss32', ct.LinearIOSystem.__add__),
1292+
(2, 2, 'rss23', ct.LinearIOSystem.__radd__),
12901293
(2, 3, 2, ct.LinearIOSystem.__add__),
12911294
(2, 3, 2, ct.LinearIOSystem.__radd__),
1292-
(2, 2, ct.rss(2, 3, 2), ct.LinearIOSystem.__sub__),
1293-
(2, 2, ct.rss(2, 2, 3), ct.LinearIOSystem.__rsub__),
1295+
(2, 2, 'rss32', ct.LinearIOSystem.__sub__),
1296+
(2, 2, 'rss23', ct.LinearIOSystem.__rsub__),
12941297
(2, 3, 2, ct.LinearIOSystem.__sub__),
12951298
(2, 3, 2, ct.LinearIOSystem.__rsub__),
12961299
])
12971300
def test_operand_incompatible(self, Pout, Pin, C, op):
12981301
P = ct.LinearIOSystem(
12991302
ct.rss(2, Pout, Pin, strictly_proper=True), name='P')
1303+
if isinstance(C, str) and C == 'rss32':
1304+
C = ct.rss(2, 3, 2)
1305+
elif isinstance(C, str) and C == 'rss23':
1306+
C = ct.rss(2, 2, 3)
13001307
with pytest.raises(ValueError, match="incompatible"):
13011308
PC = op(P, C)
13021309

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy