def _apply_filter(sys, dt, u):
# "Correct" implementation of filt that has a single time-step delay
# see Nengo issue #938
if dt is not None:
num, den = cont2discrete(sys, dt).tf
elif not sys.analog:
num, den = sys.tf
else:
raise ValueError("system (%s) must be discrete if not given dt" % sys)
# convert from the polynomial representation, and add back the leading
# zeros that were dropped by poly1d, since lfilter will shift it the
# wrong way (it will add the leading zeros back to the end, effectively
# removing the delay)
num, den = map(np.asarray, (num, den))
num = np.append([0]*(len(den) - len(num)), num)
return lfilter(num, den, u, axis=-1)
评论列表
文章目录