Skip to content

Incompatibility with scipy 1.9.0

The experimental dependencies CI workflow has started failing because the hanning window was removed in SciPY 1.9.0, see https://scipy.github.io/devdocs/release.1.9.0.html#expired-deprecations:

__ ERROR at setup of TestCliQtransform.test_filter_timeseries[highpass-filt0] __

The above exception was the direct cause of the following exception:
cls = <gwpy.cli.tests.test_qtransform.TestCliQtransform object at 0x7f5b696830d0>
prod = <gwpy.cli.qtransform.Qtransform object at 0x7f5b63f589d0>
    @classmethod
    @pytest.fixture
    def dataprod(cls, prod):
        cls._prod_add_data(prod)
>       prod.result = prod.get_spectrogram()
gwpy/cli/tests/test_spectrogram.py:37: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
gwpy/cli/qtransform.py:242: in get_spectrogram
    qtrans = proc_ts.q_transform(outseg=outseg, **self.qxfrm_args)
gwpy/timeseries/timeseries.py:2263: in q_transform
    data = self.whiten(asd=whiten, fduration=fduration,
gwpy/timeseries/timeseries.py:1747: in whiten
    tdw = filter_design.fir_from_transfer(1/asd.value, ntaps=ntaps,
gwpy/signal/filter_design.py:253: in fir_from_transfer
    impulse = truncate_impulse(impulse, ntaps=ntaps, window=window)
gwpy/signal/filter_design.py:207: in truncate_impulse
    window = signal.get_window(window, ntaps)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
window = 'hanning', Nx = 1024, fftbins = True
    def get_window(window, Nx, fftbins=True):
        """
        Return a window of a given length and type.
        Parameters
        ----------
        window : string, float, or tuple
            The type of window to create. See below for more details.
        Nx : int
            The number of samples in the window.
        fftbins : bool, optional
            If True (default), create a "periodic" window, ready to use with
            `ifftshift` and be multiplied by the result of an FFT (see also
            :func:`~scipy.fft.fftfreq`).
            If False, create a "symmetric" window, for use in filter design.
        Returns
        -------
        get_window : ndarray
            Returns a window of length `Nx` and type `window`
                0.97885093,  0.82160913,  0.56437221,  0.29425961])
        >>> signal.get_window(('exponential', None, 1.), 9)
        array([ 0.011109  ,  0.03019738,  0.082085  ,  0.22313016,  0.6065[306](https://github.com/gwpy/gwpy/runs/7072199168?check_suite_focus=true#step:8:307)6,
                0.60653066,  0.22[313](https://github.com/gwpy/gwpy/runs/7072199168?check_suite_focus=true#step:8:314)016,  0.082085  ,  0.03019738])
        >>> signal.get_window(4.0, 9)
        array([ 0.08848053,  0.29[425](https://github.com/gwpy/gwpy/runs/7072199168?check_suite_focus=true#step:8:426)961,  0.56437221,  0.82160913,  0.97885093,
                0.97885093,  0.82160913,  0.56437221,  0.29425961])
        """
        sym = not fftbins
        try:
            beta = float(window)
        except (TypeError, ValueError) as e:
            args = ()
            if isinstance(window, tuple):
                winstr = window[0]
                if len(window) > 1:
                    args = window[1:]
            elif isinstance(window, str):
                if window in _needs_param:
                    raise ValueError("The '" + window + "' window needs one or "
                                     "more parameters -- pass a tuple.") from e
                else:
                    winstr = window
            else:
                raise ValueError("%s as window type is not supported." %
                                 str(type(window))) from e
            try:
                winfunc = _win_equiv[winstr]
            except KeyError as e:
>               raise ValueError("Unknown window type.") from e
E               ValueError: Unknown window type.
/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/site-packages/scipy/signal/windows/_windows.py:2234: ValueError