@@ -57,9 +57,6 @@ def test_log_returns_from_prices():
5757 new_nan = log_rets .isnull ().sum (axis = 1 ).sum ()
5858 assert new_nan == old_nan
5959 np .testing .assert_almost_equal (log_rets .iloc [- 1 , - 1 ], 0.0001682740081102576 )
60- # Test the deprecated function, until it is removed.
61- deprecated_log_rets = expected_returns .log_returns_from_prices (df )
62- np .testing .assert_allclose (deprecated_log_rets , log_rets )
6360
6461
6562def test_mean_historical_returns_dummy ():
@@ -74,11 +71,11 @@ def test_mean_historical_returns_dummy():
7471 )
7572 mean = expected_returns .mean_historical_return (data , frequency = 1 )
7673 test_answer = pd .Series ([0.0061922 , 0.0241137 , 0.0122722 , - 0.0421775 ])
77- pd .testing .assert_series_equal (mean , test_answer , check_less_precise = 4 )
74+ pd .testing .assert_series_equal (mean , test_answer , rtol = 1e-3 )
7875
7976 mean = expected_returns .mean_historical_return (data , compounding = False , frequency = 1 )
8077 test_answer = pd .Series ([0.0086560 , 0.0250000 , 0.0128697 , - 0.03632333 ])
81- pd .testing .assert_series_equal (mean , test_answer , check_less_precise = 4 )
78+ pd .testing .assert_series_equal (mean , test_answer , rtol = 1e-3 )
8279
8380
8481def test_mean_historical_returns ():
@@ -142,10 +139,11 @@ def test_ema_historical_return():
142139 assert mean .notnull ().all ()
143140 assert mean .dtype == "float64"
144141 # Test the (warning triggering) case that input is not a dataFrame
145- mean_np = expected_returns .ema_historical_return (df .to_numpy ())
146- mean_np .name = mean .name # These will differ.
147- reset_mean = mean .reset_index (drop = True ) # Index labels would be tickers.
148- pd .testing .assert_series_equal (mean_np , reset_mean )
142+ with pytest .warns (RuntimeWarning ):
143+ mean_np = expected_returns .ema_historical_return (df .to_numpy ())
144+ mean_np .name = mean .name # These will differ.
145+ reset_mean = mean .reset_index (drop = True ) # Index labels would be tickers.
146+ pd .testing .assert_series_equal (mean_np , reset_mean )
149147
150148
151149def test_ema_historical_return_frequency ():
@@ -195,10 +193,11 @@ def test_capm_no_benchmark():
195193 )
196194 np .testing .assert_array_almost_equal (mu .values , correct_mu )
197195 # Test the (warning triggering) case that input is not a dataFrame
198- mu_np = expected_returns .capm_return (df .to_numpy ())
199- mu_np .name = mu .name # These will differ.
200- mu_np .index = mu .index # Index labels would be tickers.
201- pd .testing .assert_series_equal (mu_np , mu )
196+ with pytest .warns (RuntimeWarning ):
197+ mu_np = expected_returns .capm_return (df .to_numpy ())
198+ mu_np .name = mu .name # These will differ.
199+ mu_np .index = mu .index # Index labels would be tickers.
200+ pd .testing .assert_series_equal (mu_np , mu )
202201
203202
204203def test_capm_with_benchmark ():
0 commit comments