You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importnumpyasnpimportpybaselines# Load the dataxy=np.genfromtxt("rubberband_example.csv")
x=xy[:,0]
y=xy[:,1]
# Try the baseline (raises an error)# IndexError: arrays used as indices must be of integer (or boolean) typebl=pybaselines.Baseline(x_data=x)
bl.rubberband(y)[0]
Working example:
importscipyimportnumpyasnpdefrubberband(x: np.array, y: np.array) ->np.ndarray:
""" Based on code from Stack Exchange (Author: Roman Kiselev) Source: https://dsp.stackexchange.com/a/30723/69444 (CC BY-SA 3.0) """v=scipy.spatial.ConvexHull(np.array([x, y]).T).verticesv=np.roll(v, -v.argmin())
v=v[: (v.argmax() +1)]
bl=np.interp(x, x[v], y[v])
returnblrubberband(x,y)
Error Message
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pybaselines\_algorithm_setup.py:266 in inner
baseline, params = func(self, y, *args, **kwargs)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pybaselines\classification.py:905 in rubberband
mask[np.unique(total_vertices)] = True
IndexError: arrays used as indices must be of integer (or boolean) type
The text was updated successfully, but these errors were encountered:
Thanks for the bug report! This was caused by an incorrect handling of indices within rubberband. I fixed it on the development branch and will try to publish a new release to pypi in a week for two.
Description
I got a case, where 'rubberband' baseline fails.
However, I tried a simpler implementation from here and it worked.
Your Setup
Example Code
rubberband_example.csv
Working example:
Error Message
The text was updated successfully, but these errors were encountered: