88"""
99
1010import operator
11+ import warnings
1112
1213import numpy as np
1314import pytest
@@ -136,7 +137,6 @@ def test_constructor(self, sys322ABCD, dt, argfun):
136137 ((np .ones ((3 , 3 )), np .ones ((3 , 2 )),
137138 np .ones ((2 , 3 )), np .ones ((2 , 3 ))), ValueError ,
138139 r"Incompatible dimensions of D matrix; expected \(2, 2\)" ),
139- (([1j ], 2 , 3 , 0 ), TypeError , "real number, not 'complex'" ),
140140 ])
141141 def test_constructor_invalid (self , args , exc , errmsg ):
142142 """Test invalid input to StateSpace() constructor"""
@@ -146,6 +146,22 @@ def test_constructor_invalid(self, args, exc, errmsg):
146146 with pytest .raises (exc , match = errmsg ):
147147 ss (* args )
148148
149+ def test_constructor_complex_matrices (self ):
150+ """Test complex-valued matrices in StateSpace() constructor"""
151+ A = np .array ([[1 + 1j , 2 - 3j ], [3 + 2j , 4 - 1j ]])
152+ B = np .array ([[1 - 2j ], [3 + 4j ]])
153+ C = np .array ([[5 + 6j , 7 - 8j ]])
154+ D = np .array ([[9 + 10j ]])
155+
156+ with warnings .catch_warnings ():
157+ warnings .simplefilter ("error" )
158+ sys = StateSpace (A , B , C , D )
159+
160+ np .testing .assert_allclose (sys .A , A )
161+ np .testing .assert_allclose (sys .B , B )
162+ np .testing .assert_allclose (sys .C , C )
163+ np .testing .assert_allclose (sys .D , D )
164+
149165 def test_constructor_warns (self , sys322ABCD ):
150166 """Test ambiguos input to StateSpace() constructor"""
151167 with pytest .warns (UserWarning , match = "received multiple dt" ):
0 commit comments