From 105fe1d3edde2ac35d88b2cc2154d6effd64339a Mon Sep 17 00:00:00 2001 From: Jactus Date: Wed, 10 Mar 2021 10:38:43 +0800 Subject: [PATCH] Remove deprecated warning for numpy>=1.20.0 --- qlib/data/dataset/__init__.py | 2 +- qlib/utils/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qlib/data/dataset/__init__.py b/qlib/data/dataset/__init__.py index ecbeebc95..690436ba9 100644 --- a/qlib/data/dataset/__init__.py +++ b/qlib/data/dataset/__init__.py @@ -413,7 +413,7 @@ class TSDataSampler: # 1) for better performance, use the last nan line for padding the lost date # 2) In case of precision problems. We use np.float64. # TODO: I'm not sure if whether np.float64 will result in # precision problems. It will not cause any problems in my tests at least - indices = np.nan_to_num(indices.astype(np.float64), nan=self.nan_idx).astype(np.int) + indices = np.nan_to_num(indices.astype(np.float64), nan=self.nan_idx).astype(int) data = self.data_arr[indices] if isinstance(idx, mtit): diff --git a/qlib/utils/__init__.py b/qlib/utils/__init__.py index 6640dae2c..f550a0419 100644 --- a/qlib/utils/__init__.py +++ b/qlib/utils/__init__.py @@ -64,7 +64,7 @@ def np_ffill(arr: np.array): arr : np.array Input numpy 1D array """ - mask = np.isnan(arr.astype(np.float)) # np.isnan only works on np.float + mask = np.isnan(arr.astype(float)) # np.isnan only works on np.float # get fill index idx = np.where(~mask, np.arange(mask.shape[0]), 0) np.maximum.accumulate(idx, out=idx)