16
16
17
17
import control as ct
18
18
from control import iosys as ios
19
- from control .tests .conftest import noscipy0
19
+ from control .tests .conftest import noscipy0 , matrixfilter
20
20
21
21
class TestIOSys :
22
22
@@ -204,6 +204,8 @@ def test_linearize(self, tsys, kincar):
204
204
linearized .C , [[1 , 0 , 0 ], [0 , 1 , 0 ]])
205
205
np .testing .assert_array_almost_equal (linearized .D , np .zeros ((2 ,2 )))
206
206
207
+ @pytest .mark .usefixtures ("editsdefaults" )
208
+ @matrixfilter # avoid np.matrix warnings in v0.8.4
207
209
def test_linearize_named_signals (self , kincar ):
208
210
# Full form of the call
209
211
linearized = kincar .linearize ([0 , 0 , 0 ], [0 , 0 ], copy = True ,
@@ -217,17 +219,14 @@ def test_linearize_named_signals(self, kincar):
217
219
assert linearized .find_state ('y' ) == 1
218
220
assert linearized .find_state ('theta' ) == 2
219
221
220
- # If we copy signal names w/out a system name, append '_linearized'
221
- ct .use_legacy_defaults ('0.8.4' )
222
- ct .config .use_numpy_matrix (False ) # get rid of warning messages
222
+ # If we copy signal names w/out a system name, append '$linearized'
223
223
linearized = kincar .linearize ([0 , 0 , 0 ], [0 , 0 ], copy = True )
224
- assert linearized .name == kincar .name + '_linearized '
224
+ assert linearized .name == kincar .name + '$linearized '
225
225
226
- ct . reset_defaults ()
227
- ct .use_legacy_defaults ('0.9.0 ' )
226
+ # Test legacy version as well
227
+ ct .use_legacy_defaults ('0.8.4 ' )
228
228
linearized = kincar .linearize ([0 , 0 , 0 ], [0 , 0 ], copy = True )
229
- assert linearized .name == kincar .name + '$linearized'
230
- ct .reset_defaults ()
229
+ assert linearized .name == kincar .name + '_linearized'
231
230
232
231
# If copy is False, signal names should not be copied
233
232
lin_nocopy = kincar .linearize (0 , 0 , copy = False )
@@ -954,12 +953,13 @@ def test_named_signals(self, tsys):
954
953
np .testing .assert_array_almost_equal (ss_feedback .C , lin_feedback .C )
955
954
np .testing .assert_array_almost_equal (ss_feedback .D , lin_feedback .D )
956
955
956
+ @pytest .mark .usefixtures ("editsdefaults" )
957
+ @matrixfilter # avoid np.matrix warnings in v0.8.4
957
958
def test_sys_naming_convention (self , tsys ):
958
959
"""Enforce generic system names 'sys[i]' to be present when systems are
959
960
created without explicit names."""
960
961
961
962
ct .config .use_legacy_defaults ('0.8.4' ) # changed delims in 0.9.0
962
- ct .config .use_numpy_matrix (False ) # get rid of warning messages
963
963
ct .InputOutputSystem .idCounter = 0
964
964
sys = ct .LinearIOSystem (tsys .mimo_linsys1 )
965
965
@@ -1013,8 +1013,8 @@ def test_sys_naming_convention(self, tsys):
1013
1013
with pytest .warns (UserWarning ):
1014
1014
unnamedsys1 * unnamedsys1
1015
1015
1016
- ct . config . reset_defaults () # reset defaults
1017
-
1016
+ @ pytest . mark . usefixtures ( "editsdefaults" )
1017
+ @ matrixfilter # avoid np.matrix warnings in v0.8.4
1018
1018
def test_signals_naming_convention_0_8_4 (self , tsys ):
1019
1019
"""Enforce generic names to be present when systems are created
1020
1020
without explicit signal names:
@@ -1024,7 +1024,6 @@ def test_signals_naming_convention_0_8_4(self, tsys):
1024
1024
"""
1025
1025
1026
1026
ct .config .use_legacy_defaults ('0.8.4' ) # changed delims in 0.9.0
1027
- ct .config .use_numpy_matrix (False ) # get rid of warning messages
1028
1027
ct .InputOutputSystem .idCounter = 0
1029
1028
sys = ct .LinearIOSystem (tsys .mimo_linsys1 )
1030
1029
for statename in ["x[0]" , "x[1]" ]:
@@ -1077,8 +1076,6 @@ def test_signals_naming_convention_0_8_4(self, tsys):
1077
1076
assert "sys[1].x[0]" in same_name_series .state_index
1078
1077
assert "copy of sys[1].x[0]" in same_name_series .state_index
1079
1078
1080
- ct .config .reset_defaults () # reset defaults
1081
-
1082
1079
def test_named_signals_linearize_inconsistent (self , tsys ):
1083
1080
"""Mare sure that providing inputs or outputs not consistent with
1084
1081
updfcn or outfcn fail
@@ -1218,6 +1215,8 @@ def test_docstring_example(self):
1218
1215
np .testing .assert_array_almost_equal (io_S .C , ss_S .C )
1219
1216
np .testing .assert_array_almost_equal (io_S .D , ss_S .D )
1220
1217
1218
+ @pytest .mark .usefixtures ("editsdefaults" )
1219
+ @matrixfilter # avoid np.matrix warnings in v0.8.4
1221
1220
def test_duplicates (self , tsys ):
1222
1221
nlios = ios .NonlinearIOSystem (lambda t , x , u , params : x ,
1223
1222
lambda t , x , u , params : u * u ,
0 commit comments