Skip to content

Commit

Permalink
add ndarray.ndim==0 to test_squeeze
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed Mar 28, 2021
1 parent efb79a7 commit 4b44923
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions control/tests/lti_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,46 @@ def test_isdtime(self, objfun, arg, dt, ref, strictref):
@pytest.mark.parametrize("fcn", [ct.ss, ct.tf, ct.frd, ct.ss2io])
@pytest.mark.parametrize("nstate, nout, ninp, omega, squeeze, shape", [
[1, 1, 1, 0.1, None, ()], # SISO
[1, 1, 1, np.array(0.1), None, ()],
[1, 1, 1, [0.1], None, (1,)],
[1, 1, 1, [0.1, 1, 10], None, (3,)],
[2, 1, 1, 0.1, True, ()],
[2, 1, 1, np.array(0.1), True, ()],
[2, 1, 1, [0.1], True, ()],
[2, 1, 1, [0.1, 1, 10], True, (3,)],
[3, 1, 1, 0.1, False, (1, 1)],
[3, 1, 1, np.array(0.1), False, (1, 1)],
[3, 1, 1, [0.1], False, (1, 1, 1)],
[3, 1, 1, [0.1, 1, 10], False, (1, 1, 3)],
[1, 2, 1, 0.1, None, (2, 1)], # SIMO
[1, 2, 1, np.array(0.1), None, (2, 1)],
[1, 2, 1, [0.1], None, (2, 1, 1)],
[1, 2, 1, [0.1, 1, 10], None, (2, 1, 3)],
[2, 2, 1, 0.1, True, (2,)],
[2, 2, 1, np.array(0.1), True, (2,)],
[2, 2, 1, [0.1], True, (2,)],
[3, 2, 1, 0.1, False, (2, 1)],
[3, 2, 1, np.array(0.1), False, (2, 1)],
[3, 2, 1, [0.1], False, (2, 1, 1)],
[3, 2, 1, [0.1, 1, 10], False, (2, 1, 3)],
[1, 1, 2, [0.1, 1, 10], None, (1, 2, 3)], # MISO
[2, 1, 2, [0.1, 1, 10], True, (2, 3)],
[3, 1, 2, [0.1, 1, 10], False, (1, 2, 3)],
[1, 1, 2, 0.1, None, (1, 2)],
[1, 1, 2, np.array(0.1), None, (1, 2)],
[1, 1, 2, 0.1, True, (2,)],
[1, 1, 2, np.array(0.1), True, (2,)],
[1, 1, 2, 0.1, False, (1, 2)],
[1, 1, 2, np.array(0.1), False, (1, 2)],
[1, 2, 2, [0.1, 1, 10], None, (2, 2, 3)], # MIMO
[2, 2, 2, [0.1, 1, 10], True, (2, 2, 3)],
[3, 2, 2, [0.1, 1, 10], False, (2, 2, 3)]
[3, 2, 2, [0.1, 1, 10], False, (2, 2, 3)],
[1, 2, 2, 0.1, None, (2, 2)],
[1, 2, 2, np.array(0.1), None, (2, 2)],
[2, 2, 2, 0.1, True, (2, 2)],
[2, 2, 2, np.array(0.1), True, (2, 2)],
[3, 2, 2, 0.1, False, (2, 2)],
[3, 2, 2, np.array(0.1), False, (2, 2)],
])
def test_squeeze(self, fcn, nstate, nout, ninp, omega, squeeze, shape):
# Create the system to be tested
Expand All @@ -194,8 +212,8 @@ def test_squeeze(self, fcn, nstate, nout, ninp, omega, squeeze, shape):
sys = fcn(ct.rss(nstate, nout, ninp))

# Convert the frequency list to an array for easy of use
isscalar = not hasattr(omega, '__len__')
omega = np.array(omega)
omega = np.asarray(omega)
isscalar = omega.ndim == 0

# Call the transfer function directly and make sure shape is correct
assert sys(omega * 1j, squeeze=squeeze).shape == shape
Expand Down

0 comments on commit 4b44923

Please sign in to comment.