put fix_z0_shape before testing z0 array to handle scalar z0 case
@@ -5467,13 +5467,14 @@ def s2s(s: NumberLike, z0: NumberLike, s_def_new: str, s_def_old: str):
# Nothing to do.
return s
- if npy.isreal(z0).all():
- # Nothing to do because all port impedances are real so the used definition (power or travelling) does not make a difference.
- return s
-
nfreqs, nports, nports = s.shape
z0 = fix_z0_shape(z0, nfreqs, nports)
+ if npy.isreal(z0).all():
+ # Nothing to do because all port impedances are real so the used
+ # definition (power or travelling) does not make a difference.
+ return s
+
# Calculate port voltages and currents using the old s_def.
F, G = npy.zeros_like(s), npy.zeros_like(s)
if s_def_old == 'power':
