mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 09:24:34 +08:00
Fix deprecated syntax in numpy (#1507)
* Fix deprecated syntax in numpy * Replace np.bool with bool
This commit is contained in:
@@ -635,7 +635,7 @@ class FileOrderStrategy(BaseStrategy):
|
|||||||
self.order_df = file
|
self.order_df = file
|
||||||
else:
|
else:
|
||||||
with get_io_object(file) as f:
|
with get_io_object(file) as f:
|
||||||
self.order_df = pd.read_csv(f, dtype={"datetime": np.str})
|
self.order_df = pd.read_csv(f, dtype={"datetime": str})
|
||||||
|
|
||||||
self.order_df["datetime"] = self.order_df["datetime"].apply(pd.Timestamp)
|
self.order_df["datetime"] = self.order_df["datetime"].apply(pd.Timestamp)
|
||||||
self.order_df = self.order_df.set_index(["datetime", "instrument"])
|
self.order_df = self.order_df.set_index(["datetime", "instrument"])
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ class TSDataSampler:
|
|||||||
# NOTE: bool(np.nan) is True !!!!!!!!
|
# NOTE: bool(np.nan) is True !!!!!!!!
|
||||||
# make sure reindex comes first. Otherwise extra NaN may appear.
|
# make sure reindex comes first. Otherwise extra NaN may appear.
|
||||||
flt_data = flt_data.swaplevel()
|
flt_data = flt_data.swaplevel()
|
||||||
flt_data = flt_data.reindex(self.data_index).fillna(False).astype(np.bool)
|
flt_data = flt_data.reindex(self.data_index).fillna(False).astype(bool)
|
||||||
self.flt_data = flt_data.values
|
self.flt_data = flt_data.values
|
||||||
self.idx_map = self.flt_idx_map(self.flt_data, self.idx_map)
|
self.idx_map = self.flt_idx_map(self.flt_data, self.idx_map)
|
||||||
self.data_index = self.data_index[np.where(self.flt_data)[0]]
|
self.data_index = self.data_index[np.where(self.flt_data)[0]]
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class IndexDataTest(unittest.TestCase):
|
|||||||
self.assertTrue(np.isnan(sd.loc["bar", "g"]))
|
self.assertTrue(np.isnan(sd.loc["bar", "g"]))
|
||||||
|
|
||||||
# support slicing
|
# support slicing
|
||||||
print(sd.loc[~sd.loc[:, "g"].isna().data.astype(np.bool)])
|
print(sd.loc[~sd.loc[:, "g"].isna().data.astype(bool)])
|
||||||
|
|
||||||
print(self.assertTrue(idd.SingleData().index == idd.SingleData().index))
|
print(self.assertTrue(idd.SingleData().index == idd.SingleData().index))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user