1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-09 22:10:56 +08:00

pylint code refine & Fix nested example (#848)

* refine code by CI

* fix argument error

* fix nested eample
This commit is contained in:
you-n-g
2022-01-14 09:09:21 +08:00
committed by GitHub
parent c3996955ef
commit d0113ea7df
26 changed files with 65 additions and 68 deletions

View File

@@ -63,9 +63,7 @@ def _get_date_parse_fn(target):
get_date_parse_fn('20120101')('2017-01-01') => '20170101'
get_date_parse_fn(20120101)('2017-01-01') => 20170101
"""
if isinstance(target, pd.Timestamp):
_fn = lambda x: pd.Timestamp(x) # Timestamp('2020-01-01')
elif isinstance(target, int):
if isinstance(target, int):
_fn = lambda x: int(str(x).replace("-", "")[:8]) # 20200201
elif isinstance(target, str) and len(target) == 8:
_fn = lambda x: str(x).replace("-", "")[:8] # '20200201'
@@ -158,7 +156,7 @@ class MTSDatasetH(DatasetH):
try:
df = self.handler._learn.copy() # use copy otherwise recorder will fail
# FIXME: currently we cannot support switching from `_learn` to `_infer` for inference
except:
except Exception:
warnings.warn("cannot access `_learn`, will load raw data")
df = self.handler._data.copy()
df.index = df.index.swaplevel()