 1

# Denominator a must be 1-D.

Package:
scipy 8546
Exception Class:
ValueError

## Raise code

``````    # cases where a ValueError is more appropriate, and it allows
# b to be 2D.
b = np.atleast_1d(b)
if b.ndim != 1:
raise ValueError("Numerator b must be 1-D.")
a = np.atleast_1d(a)
if a.ndim != 1:
raise ValueError("Denominator a must be 1-D.")

while len(a) > 1 and a == 0.0:
a = a[1:]
if a.size < 1:
raise ValueError("There must be at least one nonzero `a` coefficient.")

if a != 1.0:``````
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

## Ways to fix 2 If a is set to 2D array this error is raised.

## How to to recreate the error:

```pipenv install scipy numpy
```

```from numpy import array, ones
from scipy.signal import lfilter, lfilter_zi, butter
b, a = butter(5, 0.25)
a = [a]
zi = lfilter_zi(b, a)
y, zo = lfilter(b, a, ones(10), zi=zi)
print(y)
```

```---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-33-dbc16574d684> in <module>()
2 from scipy.signal import lfilter, lfilter_zi, butter
3 b, a = butter(5, 0.25)
----> 4 zi = lfilter_zi(b, [a])
5 y, zo = lfilter(b, a, ones(10), zi=zi)
6 print(y)

/usr/local/lib/python3.7/dist-packages/scipy/signal/signaltools.py in lfilter_zi(b, a)
3589     a = np.atleast_1d(a)
3590     if a.ndim != 1:
-> 3591         raise ValueError("Denominator a must be 1-D.")
3592
3593     while len(a) > 1 and a == 0.0:

ValueError: Denominator a must be 1-D.
```

## Fixed:

```from numpy import array, ones
from scipy.signal import lfilter, lfilter_zi, butter
b, a = butter(5, 0.25)
# a = [a]
zi = lfilter_zi(b, a)
y, zo = lfilter(b, a, ones(10), zi=zi)
print(y)
```

```[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
```