# [Scipy-tickets] [SciPy] #1620: filtfilt axis argument fails

SciPy Trac scipy-tickets@scipy....
Mon Mar 12 04:20:14 CDT 2012

```#1620: filtfilt axis argument fails
--------------------+-------------------------------------------------------
Reporter:  askjak  |       Owner:  somebody
Type:  defect  |      Status:  new
Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  0.10.0
Keywords:          |
--------------------+-------------------------------------------------------
The filtfilt fails when using axis, which works as expected for lfilter.
See code below

import numpy as np
from scipy.signal import lfilter, filtfilt, butter

x = np.random.random((100,50))

b, a = butter(3, 0.05)

y1 = lfilter(b, a, x, axis=1)
y2 = lfilter(b, a, x.T, axis=0)

assert np.all(y1-y2.T==0)==True

y1 = filtfilt(b, a, x, axis=1)
y2 = filtfilt(b, a, x.T, axis=0)

Traceback (most recent call last):
File "filtfilt.py", line 15, in <module>
y2 = filtfilt(b, a, x.T, axis=0)
File "/share/distro/python/2.7.2/lib/python2.7/site-
packages/scipy/signal/signaltools.py", line 1533, in filtfilt
(y, zf) = lfilter(b, a, ext, zi=zi * x0)
File "/share/distro/python/2.7.2/lib/python2.7/site-
packages/scipy/signal/signaltools.py", line 581, in lfilter
return sigtools._linear_filter(b, a, x, axis, zi)
ValueError: The number of initial conditions must be max([len(a),len(b)])
- 1

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1620>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```