Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Example:
>>> def pos(x): return x > 0
>>> compute_perfect_model(ds, control, metric='brier_score', logical=pos)
"""
if 'logical' in metric_kwargs:
logical = metric_kwargs['logical']
if not callable(logical):
raise ValueError(f'`logical` must be `callable`, found {type(logical)}')
else:
raise ValueError(
'Please provide a callable `logical` to be applied to comparison and \
verification data to get values in interval [0,1]; \
see properscoring.brier_score.'
)
return brier_score(logical(verif), logical(forecast).mean('member'))