diff --git a/deltasigma/_utils.py b/deltasigma/_utils.py index 097f803..679be82 100644 --- a/deltasigma/_utils.py +++ b/deltasigma/_utils.py @@ -91,7 +91,7 @@ def carray(x): """Check that x is an ndarray. If not, try to convert it to ndarray. """ if not isinstance(x, np.ndarray): - if not isinstance(x, collections.Iterable): + if not isinstance(x, collections.abc.Iterable): x = np.array((x,)) else: x = np.array(x) @@ -448,7 +448,7 @@ def _get_zpk(arg, input=0): z, p, k = sys.zeros, sys.poles, sys.gain elif _is_A_B_C_D(arg): z, p, k = ss2zpk(*arg, input=input) - elif isinstance(arg, collections.Iterable): + elif isinstance(arg, collections.abc.Iterable): ri = 0 for i in arg: # Note we do not check if the user has assembled a list with @@ -528,7 +528,7 @@ def _get_num_den(arg, input=0): num, den = zpk2tf(*arg) elif _is_A_B_C_D(arg): num, den = ss2tf(*arg, input=input) - elif isinstance(arg, collections.Iterable): + elif isinstance(arg, collections.abc.Iterable): ri = 0 for i in arg: # Note we do not check if the user has assembled a list with @@ -610,7 +610,7 @@ def _getABCD(arg): elif _is_zpk(arg) or _is_num_den(arg) or _is_A_B_C_D(arg): sys = lti(*arg).to_ss() A, B, C, D = sys.A, sys.B, sys.C, sys.D - elif isinstance(arg, collections.Iterable): + elif isinstance(arg, collections.abc.Iterable): A, B, C, D = None, None, None, None for i in arg: # Note we do not check if the user has assembled a list with @@ -641,25 +641,25 @@ def _getABCD(arg): def _is_zpk(arg): """Can the argument be safely assumed to be a zpk tuple?""" - return isinstance(arg, collections.Iterable) and len(arg) == 3 and \ - isinstance(arg[0], collections.Iterable) and \ - isinstance(arg[1], collections.Iterable) and np.isscalar(arg[2]) + return isinstance(arg, collections.abc.Iterable) and len(arg) == 3 and \ + isinstance(arg[0], collections.abc.Iterable) and \ + isinstance(arg[1], collections.abc.Iterable) and np.isscalar(arg[2]) def _is_num_den(arg): """Can the argument be safely assumed to be a num, den tuple?""" - return isinstance(arg, collections.Iterable) and len(arg) == 2 and \ - isinstance(arg[0], collections.Iterable) and \ - isinstance(arg[1], collections.Iterable) + return isinstance(arg, collections.abc.Iterable) and len(arg) == 2 and \ + isinstance(arg[0], collections.abc.Iterable) and \ + isinstance(arg[1], collections.abc.Iterable) def _is_A_B_C_D(arg): """Can the argument be safely assumed to be an (A, B, C, D) tuple?""" - return isinstance(arg, collections.Iterable) and len(arg) == 4 and \ - (isinstance(arg[0], collections.Iterable) or np.is_scalar(arg[0])) and \ - (isinstance(arg[1], collections.Iterable) or np.is_scalar(arg[1])) and \ - (isinstance(arg[2], collections.Iterable) or np.is_scalar(arg[2])) and \ - (isinstance(arg[3], collections.Iterable) or np.is_scalar(arg[3])) + return isinstance(arg, collections.abc.Iterable) and len(arg) == 4 and \ + (isinstance(arg[0], collections.abc.Iterable) or np.is_scalar(arg[0])) and \ + (isinstance(arg[1], collections.abc.Iterable) or np.is_scalar(arg[1])) and \ + (isinstance(arg[2], collections.abc.Iterable) or np.is_scalar(arg[2])) and \ + (isinstance(arg[3], collections.abc.Iterable) or np.is_scalar(arg[3])) def mround(x):