From bb2499939f7665dc8ac38fd2ae6a5c9929a345f8 Mon Sep 17 00:00:00 2001 From: Kamil <32775019+quant12345@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:53:32 +0500 Subject: [PATCH] numpy 2.0 replacing deprecated namespace (#2553) Co-authored-by: madtoinou <32447896+madtoinou@users.noreply.github.com> Co-authored-by: Dennis Bader --- darts/ad/detectors/threshold_detector.py | 4 ++-- darts/models/forecasting/fft.py | 2 +- darts/models/forecasting/forecasting_model.py | 2 +- darts/utils/losses.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/darts/ad/detectors/threshold_detector.py b/darts/ad/detectors/threshold_detector.py index 7a0eac4324..1d89d90a99 100644 --- a/darts/ad/detectors/threshold_detector.py +++ b/darts/ad/detectors/threshold_detector.py @@ -80,8 +80,8 @@ def _detect_core(self, series: TimeSeries, name: str = "series") -> TimeSeries: def _detect_fn(x, lo, hi): # x of shape (time,) for 1 component - return (x < (np.NINF if lo is None else lo)) | ( - x > (np.Inf if hi is None else hi) + return (x < (-np.inf if lo is None else lo)) | ( + x > (np.inf if hi is None else hi) ) detected = np.zeros_like(np_series, dtype=int) diff --git a/darts/models/forecasting/fft.py b/darts/models/forecasting/fft.py index 35d2f67583..2143c917c5 100644 --- a/darts/models/forecasting/fft.py +++ b/darts/models/forecasting/fft.py @@ -356,7 +356,7 @@ def fit(self, series: TimeSeries): ] # set all other values in the frequency domain to 0 - self.fft_values_filtered = np.zeros(len(self.fft_values), dtype=np.complex_) + self.fft_values_filtered = np.zeros(len(self.fft_values), dtype=np.complex128) self.fft_values_filtered[self.filtered_indices] = self.fft_values[ self.filtered_indices ] diff --git a/darts/models/forecasting/forecasting_model.py b/darts/models/forecasting/forecasting_model.py index dfcbe9de13..c191fd1e3d 100644 --- a/darts/models/forecasting/forecasting_model.py +++ b/darts/models/forecasting/forecasting_model.py @@ -1120,7 +1120,7 @@ def retrain_func( length=1, freq=series_.freq, ), - values=np.array([np.NaN]), + values=np.array([np.nan]), ) forecast = model._predict_wrapper( diff --git a/darts/utils/losses.py b/darts/utils/losses.py index 2c51e71145..948660e791 100644 --- a/darts/utils/losses.py +++ b/darts/utils/losses.py @@ -17,7 +17,7 @@ def _divide_no_nan(a, b): result = a / b result[result != result] = 0.0 result[result == np.inf] = 0.0 - result[result == np.NINF] = 0.0 + result[result == -np.inf] = 0.0 return result