cov_from_df = risk_models.sample_cov(df)
returns_as_array = np.array(df)
with warnings.catch_warnings(record=True) as w:
cov_from_array = risk_models.sample_cov(returns_as_array)
assert len(w) == 1
assert issubclass(w[0].category, RuntimeWarning)
assert str(w[0].message) == "data is not in a dataframe"
np.testing.assert_array_almost_equal(
cov_from_df.values, cov_from_array.values, decimal=6
After Change
cov_from_df = risk_models.sample_cov(df)
returns_as_array = np.array(df)
with pytest.warns(RuntimeWarning) as w:
cov_from_array = risk_models.sample_cov(returns_as_array)
assert len(w) == 1
assert str(w[0].message) == "data is not in a dataframe"