add ndarray.ndim==0 to test_squeeze · python-control/python-control@4b44923

@@ -160,28 +160,46 @@ def test_isdtime(self, objfun, arg, dt, ref, strictref):

160160

@pytest.mark.parametrize("fcn", [ct.ss, ct.tf, ct.frd, ct.ss2io])

161161

@pytest.mark.parametrize("nstate, nout, ninp, omega, squeeze, shape", [

162162

[1, 1, 1, 0.1, None, ()], # SISO

163+

[1, 1, 1, np.array(0.1), None, ()],

163164

[1, 1, 1, [0.1], None, (1,)],

164165

[1, 1, 1, [0.1, 1, 10], None, (3,)],

165166

[2, 1, 1, 0.1, True, ()],

167+

[2, 1, 1, np.array(0.1), True, ()],

166168

[2, 1, 1, [0.1], True, ()],

167169

[2, 1, 1, [0.1, 1, 10], True, (3,)],

168170

[3, 1, 1, 0.1, False, (1, 1)],

171+

[3, 1, 1, np.array(0.1), False, (1, 1)],

169172

[3, 1, 1, [0.1], False, (1, 1, 1)],

170173

[3, 1, 1, [0.1, 1, 10], False, (1, 1, 3)],

171174

[1, 2, 1, 0.1, None, (2, 1)], # SIMO

175+

[1, 2, 1, np.array(0.1), None, (2, 1)],

172176

[1, 2, 1, [0.1], None, (2, 1, 1)],

173177

[1, 2, 1, [0.1, 1, 10], None, (2, 1, 3)],

174178

[2, 2, 1, 0.1, True, (2,)],

179+

[2, 2, 1, np.array(0.1), True, (2,)],

175180

[2, 2, 1, [0.1], True, (2,)],

176181

[3, 2, 1, 0.1, False, (2, 1)],

182+

[3, 2, 1, np.array(0.1), False, (2, 1)],

177183

[3, 2, 1, [0.1], False, (2, 1, 1)],

178184

[3, 2, 1, [0.1, 1, 10], False, (2, 1, 3)],

179185

[1, 1, 2, [0.1, 1, 10], None, (1, 2, 3)], # MISO

180186

[2, 1, 2, [0.1, 1, 10], True, (2, 3)],

181187

[3, 1, 2, [0.1, 1, 10], False, (1, 2, 3)],

188+

[1, 1, 2, 0.1, None, (1, 2)],

189+

[1, 1, 2, np.array(0.1), None, (1, 2)],

190+

[1, 1, 2, 0.1, True, (2,)],

191+

[1, 1, 2, np.array(0.1), True, (2,)],

192+

[1, 1, 2, 0.1, False, (1, 2)],

193+

[1, 1, 2, np.array(0.1), False, (1, 2)],

182194

[1, 2, 2, [0.1, 1, 10], None, (2, 2, 3)], # MIMO

183195

[2, 2, 2, [0.1, 1, 10], True, (2, 2, 3)],

184-

[3, 2, 2, [0.1, 1, 10], False, (2, 2, 3)]

196+

[3, 2, 2, [0.1, 1, 10], False, (2, 2, 3)],

197+

[1, 2, 2, 0.1, None, (2, 2)],

198+

[1, 2, 2, np.array(0.1), None, (2, 2)],

199+

[2, 2, 2, 0.1, True, (2, 2)],

200+

[2, 2, 2, np.array(0.1), True, (2, 2)],

201+

[3, 2, 2, 0.1, False, (2, 2)],

202+

[3, 2, 2, np.array(0.1), False, (2, 2)],

185203

])

186204

def test_squeeze(self, fcn, nstate, nout, ninp, omega, squeeze, shape):

187205

# Create the system to be tested

@@ -194,8 +212,8 @@ def test_squeeze(self, fcn, nstate, nout, ninp, omega, squeeze, shape):

194212

sys = fcn(ct.rss(nstate, nout, ninp))

195213196214

# Convert the frequency list to an array for easy of use

197-

isscalar = not hasattr(omega, '__len__')

198-

omega = np.array(omega)

215+

omega = np.asarray(omega)

216+

isscalar = omega.ndim == 0

199217200218

# Call the transfer function directly and make sure shape is correct

201219

assert sys(omega * 1j, squeeze=squeeze).shape == shape