ermshaua / claspy

ClaSPy: A Python package for time series segmentation.
BSD 3-Clause "New" or "Revised" License
81 stars 3 forks source link

NumbaTypeSafetyWarning when running demo code snippets #13

Closed Andreasbirch closed 1 month ago

Andreasbirch commented 1 month ago

Hello, I am trying to run the code snippets for the usage examples provided in the readme.

This is my code for the univariate time series:

from claspy.segmentation import BinaryClaSPSegmentation
from claspy.data_loader import load_tssb_dataset

dataset, window_size, true_cps, time_series = load_tssb_dataset(names=("CricketX")).iloc[0,:]
clasp = BinaryClaSPSegmentation()
clasp.fit_predict(time_series)

And for the multivariate time series:

from claspy.segmentation import BinaryClaSPSegmentation
from claspy.data_loader import load_has_dataset
dataset, window_size, true_cps, labels, time_series = load_has_dataset().iloc[107, :]
clasp = BinaryClaSPSegmentation()
clasp.fit_predict(time_series)

In both cases I get the same error:

/Users/me/PycharmProjects/TimeSeriesSegmenter/.venv/lib/python3.11/site-packages/claspy/nearest_neighbour.py:252: NumbaTypeSafetyWarning: unsafe cast from uint64 to int64. Precision may be lost.
  start, end = pranges[idx]
ermshaua commented 1 month ago

Do you get an error that stops your program or just a warning? Until now, this was just a warning. Haven't fixed it yet.

Andreasbirch commented 1 month ago

The warning stops the program. I was able to circumvent it by adding

from numba.core.errors import NumbaTypeSafetyWarning
import warnings
warnings.simplefilter(action='ignore', category=NumbaTypeSafetyWarning)

To the nearest_neighbour.py file. I found the documentation for the solution here

ermshaua commented 1 month ago

Thanks! I'll have a look.

ermshaua commented 1 month ago

Should now be fixed in 0.2.4. Can you upgrade and verify?

Andreasbirch commented 1 month ago

Looks good - no warnings anymore! Thank you for your help.