quantopian / empyrical

Common financial risk and performance metrics. Used by zipline and pyfolio.
https://quantopian.github.io/empyrical
Apache License 2.0
1.31k stars 406 forks source link

TST: Change noop assertions to check for nan #31

Closed richafrank closed 8 years ago

richafrank commented 8 years ago

(Everything is not equal to nan!)

richafrank commented 8 years ago

@twiecki I changed these assertions from being trivially true, since everything evaluates not equal to nan, and now one of them fails. I'm not sure if the test or the risk function(s) should be changed. What are your thoughts?

richafrank commented 8 years ago

Specifically, the test that fails is test_alpha_beta_with_nan_inputs_0.

twiecki commented 8 years ago

I think the problem is not the nans in the input here but instead the flat-line we pass in for benchmark. @ahgnaw can we replace all of those with non-flat lines? I'm not sure what relevant case we're testing there.

analicia commented 8 years ago

The flat line here is wrongly used as an input. The alpha and beta values of any return series against a flat line will return np.nan. In other tests, the flat line is used as a sanity check, e.g. test_alpha_2. Getting rid of all tests that use a flat line as a benchmark would remove some property tests.

analicia commented 8 years ago

LGTM

twiecki commented 8 years ago

:+1: