scientisst / BioSPPy

Biosignal Processing in Python
https://biosppy.readthedocs.io/
Other
66 stars 21 forks source link

The window functions can not be accessed directly in the scipy.signal module from scipy version 1.13 #42

Closed wenh06 closed 5 months ago

wenh06 commented 5 months ago

Scipy released version 1.13.0 a few days ago (2024/04/03). The window functions can not be accessed directly in the scipy.signal module from this version, otherwise it would raise errors like the following:

/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/biosppy/signals/ecg.py:1053: in hamilton_segmenter
    dx, _ = st.smoother(signal=dx, kernel="hamming", size=sm_size, mirror=True)
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/biosppy/signals/tools.py:606: in smoother
    win = _get_window(kernel, size, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

kernel = 'hamming', size = 40, kwargs = {}

    def _get_window(kernel, size, **kwargs):
        """Return a window with the specified parameters.

        Parameters
        ----------
        kernel : str
            Type of window to create.
        size : int
            Size of the window.
        ``**kwargs`` : dict, optional
            Additional keyword arguments are passed to the underlying
            scipy.signal.windows function.

        Returns
        -------
        window : array
            Created window.

        """

        # mimics scipy.signal.get_window
        if kernel in ["blackman", "black", "blk"]:
            winfunc = ss.blackman
        elif kernel in ["triangle", "triang", "tri"]:
            winfunc = ss.triang
        elif kernel in ["hamming", "hamm", "ham"]:
>           winfunc = ss.hamming
E           AttributeError: module 'scipy.signal' has no attribute 'hamming'

In stead, one can access window functions through the scipy.signal.window module, or via the function scipy.signal.get_window.

wenh06 commented 5 months ago

I noticed that this issue was fixed in #18. Can you make a new release to PyPI?

rafaelscsilva commented 5 months ago

Thank you @wenh06 for bringing this to our attention! We will make a new release soon :)