Skip to content

Commit

Permalink
Change collections.Iterable to collections.abc.Iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Fukuda authored Mar 6, 2022
1 parent 030a238 commit d33ef4e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions deltasigma/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d33ef4e

Please sign in to comment.