Repository: scipy/scipy

Issue:
ENH: signal.gauss_spline should accept a list
<!-- 
Thank you for taking the time to file a bug report. 
Please fill in the fields below, deleting the sections that 
don't apply to your issue. You can view the final output
by clicking the preview button above.
Note: This is a comment, and won't appear in the output.
-->

My issue is about ...

I found an API inconsistency of `signal.gauss_spline`.

#### Reproducing code example:

The signal module has several Bspline basis functions: `bspline`, `cubic`, `quadratic`, `gauss_spline`.

These functions can accept numpy.array.

```
from scipy.signal import gauss_spline, bspline, cubic, quadratic
knots = np.array([-1.0, 0.0, -1.0])
print(bspline(knots, 3))
# [0.16666667 0.66666667 0.16666667]
print(cubic(knots))
# [0.16666667 0.66666667 0.16666667]
print(quadratic(knots))
# [0.125 0.75  0.125]
print(gauss_spline(knots, 3))
# [0.15418033 0.6909883  0.15418033]
```

But only `gauss_spline` can not accept a list, but others can accept a list.

```
knots = [-1.0, 0.0, -1.0]
print(bspline(knots, 3))
# [0.16666667 0.66666667 0.16666667]
print(cubic(knots))
# [0.16666667 0.66666667 0.16666667]
print(quadratic(knots))
# [0.125 0.75  0.125]
print(gauss_spline(knots, 3))
# Traceback (most recent call last):
#   File "/Users/atsushisakai/PycharmProjects/python_sandbox/scipy_test/spline_signal_filter.py", line 57, in <module>
#     print(gauss_spline(knots, 3))
#   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scipy/signal/bsplines.py", line 149, in gauss_spline
#     return 1 / sqrt(2 * pi * signsq) * exp(-x ** 2 / 2 / signsq)
# TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'
```

I think it should accept it for API consistency.

#### Scipy/Numpy/Python version information:
<!-- You can simply run the following and paste the result in a code block
```
import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
```
-->
scipy: 1.4.1


Discussion:

Resolving patch:
diff --git a/scipy/signal/bsplines.py b/scipy/signal/bsplines.py
--- a/scipy/signal/bsplines.py
+++ b/scipy/signal/bsplines.py
@@ -239,6 +239,7 @@ def gauss_spline(x, n):
     array([0.16666667, 0.66666667, 0.16666667])  # may vary
 
     """
+    x = asarray(x)
     signsq = (n + 1) / 12.0
     return 1 / sqrt(2 * pi * signsq) * exp(-x ** 2 / 2 / signsq)
 


Test patch:
diff --git a/scipy/signal/tests/test_bsplines.py b/scipy/signal/tests/test_bsplines.py
--- a/scipy/signal/tests/test_bsplines.py
+++ b/scipy/signal/tests/test_bsplines.py
@@ -123,6 +123,12 @@ def test_gauss_spline(self):
         assert_almost_equal(bsp.gauss_spline(0, 0), 1.381976597885342)
         assert_allclose(bsp.gauss_spline(array([1.]), 1), array([0.04865217]))
 
+    def test_gauss_spline_list(self):
+        # regression test for gh-12152 (accept array_like)
+        knots = [-1.0, 0.0, -1.0]
+        assert_almost_equal(bsp.gauss_spline(knots, 3),
+                            array([0.15418033, 0.6909883, 0.15418033]))
+
     def test_cubic(self):
         np.random.seed(12460)
         assert_array_equal(bsp.cubic([0]), array([0]))