[SciPy-dev] Apparently bug in filter_design.py
Joachim Saul
list at jsaul.de
Tue Dec 9 16:32:17 CST 2003
Hi there,
while using a IIR filter designed using scipy.signal.iirfilter, an
error occurs within lp2bp() and potentially in the other similar
routines as well, where the line
aprime[Dp-j] = val
occurs. Since val can be complex, and aprime be e.g. of double type, an
error may be (and im my situation is) issued:
TypeError: can't convert complex to float; use abs(z)
Which, in turn, doesn't quite make sense, at least *if* a real
part of the values in aprime may be negative.
A quick fix would be to modify lp2bp():
replace
bprime = Num.zeros(Np+1,artype)
aprime = Num.zeros(Dp+1,artype)
by
bprime = Num.zeros(Np+1, 'D')
aprime = Num.zeros(Dp+1, 'D')
and just before "return" add
bprime = bprime.astype(artype)
aprime = aprime.astype(artype)
This would force aprime and bprime to be always double precision
complex (which should never harm) and at the end cast to the
originally wanted type. Since this is used in filter design only,
the overhead though the conversion would be negligible.
Any comments?
Cheers,
Joachim
More information about the Scipy-dev
mailing list