Repository: scipy/scipy

Issue:
`signal.get_window` does not support `general_cosine` and `general_hamming`.
`signal.get_window` is supporting almost window functions in `signal.windows`.
But, [general\_cosine](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.windows.general_cosine.html) and [general\_hamming ](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.windows.general_hamming.html) are not supported yet:
```
>>> windows.general_cosine(4, [0.5, 0.3, 0.2])
array([0.4 , 0.55, 0.55, 0.4 ])
>>> get_window(("general_cosine", [0.5, 0.3, 0.2]), 4)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2126, in get_window
    beta = float(window)
TypeError: float() argument must be a string or a number, not 'tuple'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2144, in get_window
    winfunc = _win_equiv[winstr]
KeyError: 'general_cosine'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2146, in get_window
    raise ValueError("Unknown window type.") from e
ValueError: Unknown window type.
```
```
>>> windows.general_hamming(5, 0.7)
array([0.4, 0.7, 1. , 0.7, 0.4])
>>> get_window(("general_hamming", 0.7), 5)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2126, in get_window
    beta = float(window)
TypeError: float() argument must be a string or a number, not 'tuple'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2144, in get_window
    winfunc = _win_equiv[winstr]
KeyError: 'general_hamming'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/scipy/signal/windows/windows.py", line 2146, in get_window
    raise ValueError("Unknown window type.") from e
ValueError: Unknown window type.
```
I think that these should be supported for API consistency.

SciPy:1.6.2


Discussion:

Resolving patch:
diff --git a/scipy/signal/windows/windows.py b/scipy/signal/windows/windows.py
--- a/scipy/signal/windows/windows.py
+++ b/scipy/signal/windows/windows.py
@@ -2021,8 +2021,10 @@ def _fftautocorr(x):
     ('exponential', 'poisson'): (exponential, False),
     ('flattop', 'flat', 'flt'): (flattop, False),
     ('gaussian', 'gauss', 'gss'): (gaussian, True),
+    ('general cosine', 'general_cosine'): (general_cosine, True),
     ('general gaussian', 'general_gaussian',
         'general gauss', 'general_gauss', 'ggs'): (general_gaussian, True),
+    ('general hamming', 'general_hamming'): (general_hamming, True),
     ('hamming', 'hamm', 'ham'): (hamming, False),
     ('hanning', 'hann', 'han'): (hann, False),
     ('kaiser', 'ksr'): (kaiser, True),
@@ -2089,7 +2091,9 @@ def get_window(window, Nx, fftbins=True):
     - `~scipy.signal.windows.taylor`
     - `~scipy.signal.windows.kaiser` (needs beta)
     - `~scipy.signal.windows.gaussian` (needs standard deviation)
+    - `~scipy.signal.windows.general_cosine` (needs weighting coefficients)
     - `~scipy.signal.windows.general_gaussian` (needs power, width)
+    - `~scipy.signal.windows.general_hamming` (needs window coefficient)
     - `~scipy.signal.windows.dpss` (needs normalized half-bandwidth)
     - `~scipy.signal.windows.chebwin` (needs attenuation)
 


Test patch:
diff --git a/scipy/signal/tests/test_windows.py b/scipy/signal/tests/test_windows.py
--- a/scipy/signal/tests/test_windows.py
+++ b/scipy/signal/tests/test_windows.py
@@ -643,6 +643,19 @@ def test_array_as_window(self):
         with assert_raises(ValueError, match='must have the same length'):
             resample(sig, len(sig) * osfactor, window=win)
 
+    def test_general_cosine(self):
+        assert_allclose(get_window(('general_cosine', [0.5, 0.3, 0.2]), 4),
+                        [0.4, 0.3, 1, 0.3])
+        assert_allclose(get_window(('general_cosine', [0.5, 0.3, 0.2]), 4,
+                                   fftbins=False),
+                        [0.4, 0.55, 0.55, 0.4])
+
+    def test_general_hamming(self):
+        assert_allclose(get_window(('general_hamming', 0.7), 5),
+                        [0.4, 0.6072949, 0.9427051, 0.9427051, 0.6072949])
+        assert_allclose(get_window(('general_hamming', 0.7), 5, fftbins=False),
+                        [0.4, 0.7, 1.0, 0.7, 0.4])
+
 
 def test_windowfunc_basics():
     for window_name, params in window_funcs:
@@ -701,8 +714,8 @@ def test_needs_params():
     for winstr in ['kaiser', 'ksr', 'gaussian', 'gauss', 'gss',
                    'general gaussian', 'general_gaussian',
                    'general gauss', 'general_gauss', 'ggs',
-                   'dss', 'dpss',
-                   'chebwin', 'cheb',
+                   'dss', 'dpss', 'general cosine', 'general_cosine',
+                   'chebwin', 'cheb', 'general hamming', 'general_hamming',
                    ]:
         assert_raises(ValueError, get_window, winstr, 7)