mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-12 19:06:35 +08:00
MAINT: Refactor check_entry method to also look at np.inf
Also, make the method a module function.
This commit is contained in:
+9
-16
@@ -78,6 +78,15 @@ TREASURY_DURATIONS = [
|
||||
]
|
||||
|
||||
|
||||
# check if a field in rval is nan, and replace it with
|
||||
# None.
|
||||
def check_entry(key, value):
|
||||
if key != 'period_label':
|
||||
return np.isnan(value) or np.isinf(value)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
############################
|
||||
# Risk Metric Calculations #
|
||||
############################
|
||||
@@ -378,14 +387,6 @@ class RiskMetricsBase(object):
|
||||
'period_label': period_label
|
||||
}
|
||||
|
||||
# check if a field in rval is nan, and replace it with
|
||||
# None.
|
||||
def check_entry(key, value):
|
||||
if key != 'period_label':
|
||||
return np.isnan(value)
|
||||
else:
|
||||
return False
|
||||
|
||||
return {k: None if check_entry(k, v) else v
|
||||
for k, v in rval.iteritems()}
|
||||
|
||||
@@ -703,14 +704,6 @@ algorithm_returns ({algo_count}) in range {start} : {end} on {dt}"
|
||||
rval['sortino'] = 0.0
|
||||
rval['information'] = 0.0
|
||||
|
||||
# check if a field in rval is nan, and replace it with
|
||||
# None.
|
||||
def check_entry(key, value):
|
||||
if key != 'period_label':
|
||||
return np.isnan(value)
|
||||
else:
|
||||
return False
|
||||
|
||||
return {k: None
|
||||
if check_entry(k, v)
|
||||
else v for k, v in rval.iteritems()}
|
||||
|
||||
Reference in New Issue
Block a user