Skip to content

Commit 05e6fe6

Browse files
committed
get rid of warnings in unit tests
1 parent 8bb8e22 commit 05e6fe6

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

control/tests/matlab_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ def testLsim(self, siso):
321321
yout, tout, _xout = lsim(siso.ss1, u, t)
322322
np.testing.assert_array_almost_equal(yout, youttrue, decimal=4)
323323
np.testing.assert_array_almost_equal(tout, t)
324-
yout, _t, _xout = lsim(siso.tf3, u, t)
324+
with pytest.warns(UserWarning, match="Internal conversion"):
325+
yout, _t, _xout = lsim(siso.tf3, u, t)
325326
np.testing.assert_array_almost_equal(yout, youttrue, decimal=4)
326327

327328
# test with initial value and special algorithm for ``U=0``

control/tests/timeresp_test.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -723,26 +723,26 @@ def test_time_series_data_convention_2D(self, siso_ss1):
723723
assert y.ndim == 1 # SISO returns "scalar" output
724724
assert t.shape == y.shape # Allows direct plotting of output
725725

726-
@pytest.mark.usefixtures("editsdefaults")
727726
@pytest.mark.parametrize("fcn", [ct.ss, ct.tf, ct.ss2io])
728727
@pytest.mark.parametrize("nstate, nout, ninp, squeeze, shape", [
729728
[1, 1, 1, None, (8,)],
730729
[2, 1, 1, True, (8,)],
731730
[3, 1, 1, False, (1, 8)],
732731
# [4, 1, 1, 'siso', (8,)], # Use for later 'siso' implementation
733-
[1, 2, 1, None, (2, 8)],
734-
[2, 2, 1, True, (2, 8)],
735-
[3, 2, 1, False, (2, 8)],
736-
# [4, 2, 1, 'siso', (2, 8)], # Use for later 'siso' implementation
737-
[1, 1, 2, None, (8,)],
738-
[2, 1, 2, True, (8,)],
739-
[3, 1, 2, False, (1, 8)],
740-
# [4, 1, 2, 'siso', (1, 8)], # Use for later 'siso' implementation
741-
[1, 2, 2, None, (2, 8)],
742-
[2, 2, 2, True, (2, 8)],
743-
[3, 2, 2, False, (2, 8)],
744-
# [4, 2, 2, 'siso', (2, 8)], # Use for later 'siso' implementation
732+
[3, 2, 1, None, (2, 8)],
733+
[4, 2, 1, True, (2, 8)],
734+
[5, 2, 1, False, (2, 8)],
735+
# [6, 2, 1, 'siso', (2, 8)], # Use for later 'siso' implementation
736+
[3, 1, 2, None, (8,)],
737+
[4, 1, 2, True, (8,)],
738+
[5, 1, 2, False, (1, 8)],
739+
# [6, 1, 2, 'siso', (1, 8)], # Use for later 'siso' implementation
740+
[4, 2, 2, None, (2, 8)],
741+
[5, 2, 2, True, (2, 8)],
742+
[6, 2, 2, False, (2, 8)],
743+
# [7, 2, 2, 'siso', (2, 8)], # Use for later 'siso' implementation
745744
])
745+
@pytest.mark.usefixtures("editsdefaults")
746746
def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape):
747747
# Figure out if we have SciPy 1+
748748
scipy0 = StrictVersion(sp.__version__) < '1.0'
@@ -818,13 +818,13 @@ def test_squeeze(self, fcn, nstate, nout, ninp, squeeze, shape):
818818
_, yvec = ct.step_response(sys, tvec)
819819
assert yvec.shape == (sys.outputs, 8)
820820

821-
_, yvec, xvec = ct.forced_response(
822-
sys, tvec, uvec, 0, return_x=True)
823-
assert yvec.shape == (sys.outputs, 8)
824821
if isinstance(sys, ct.StateSpace):
822+
_, yvec, xvec = ct.forced_response(
823+
sys, tvec, uvec, 0, return_x=True)
825824
assert xvec.shape == (sys.states, 8)
826825
else:
827-
assert xvec.shape[1] == 8
826+
_, yvec = ct.forced_response(sys, tvec, uvec, 0)
827+
assert yvec.shape == (sys.outputs, 8)
828828

829829
# For InputOutputSystems, also test input_output_response
830830
if isinstance(sys, ct.InputOutputSystem) and not scipy0:

control/timeresp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,10 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
285285
return_x = config.defaults['forced_response.return_x']
286286

287287
# If return_x is used for TransferFunction, issue a warning
288-
if return_x and not isinstance(sys, TransferFunction):
288+
if return_x and isinstance(sys, TransferFunction):
289289
warnings.warn(
290290
"return_x specified for a transfer function system. Internal "
291-
"conversation to state space used; results may meaningless.")
291+
"conversion to state space used; results may meaningless.")
292292

293293
sys = _convert_to_statespace(sys)
294294
A, B, C, D = np.asarray(sys.A), np.asarray(sys.B), np.asarray(sys.C), \

0 commit comments

Comments
 (0)