[SciPy-dev] patch for filter_design.py in scipy.signal

Heiko Henkelmann heiko at hhenkelmann.de
Fri Jun 7 16:43:01 EDT 2002


Hello there,

I found the following problem:


ActivePython 2.1, build 210 ActiveState)
based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy import signal
>>> signal.butter(6,0.5)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\usr\python21\scipy\signal\filter_design.py", line 484, in butter
    return iirfilter(N, Wn, btype=btype, analog=analog, output=output,
ftype='butter')
  File "c:\usr\python21\scipy\signal\filter_design.py", line 465, in
iirfilter
    b, a = bilinear(b, a, fs=fs)
  File "c:\usr\python21\scipy\signal\filter_design.py", line 313, in
bilinear
    bprime[j] = val
TypeError: can't convert complex to float; use e.g. abs(z)
>>>


The following patch fixes it:


*** C:\WINDOWS\TEMP\filter_design.py Fri Jun  7 22:32:30 2002
--- C:\WINDOWS\TEMP\filter_design.pyF9gqgq Fri Jun  7 22:32:30 2002
***************
*** 448,453 ****
--- 448,456 ----
          z, p, k = typefunc(N, rp, rs)

      b, a = zpk2tf(z,p,k)
+     if a.typecode() in ['F','D']:
+         # we are dealing with real filter coefficients
+         a = a.real.copy()

      # transform to lowpass, bandpass, highpass, or bandstop
      if btype == 'lowpass':


Can anyone apply this to the CVS repository?


Thanx

Heiko





More information about the SciPy-Dev mailing list