From 8858ef03a9a2eb0b14f21c4bcc8a0c247d07c3a5 Mon Sep 17 00:00:00 2001 From: quant Date: Fri, 4 Oct 2024 16:10:44 +0500 Subject: [PATCH] numpy 2.0 replacing deprecated namespace --- 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 7e3affd007..e2daa89ed4 100644 --- a/darts/ad/detectors/threshold_detector.py +++ b/darts/ad/detectors/threshold_detector.py @@ -79,8 +79,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 ee271ceed6..41a1e44224 100644 --- a/darts/models/forecasting/forecasting_model.py +++ b/darts/models/forecasting/forecasting_model.py @@ -1122,7 +1122,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