def test_min_cov_det(): df = get_data() S = risk_models.min_cov_determinant(df, random_state=8) assert S.shape == (20, 20) assert S.index.equals(df.columns) assert S.index.equals(S.columns) assert S.notnull().all().all() S2 = risk_models.min_cov_determinant(df, frequency=2, random_state=8) pd.testing.assert_frame_equal(S / 126, S2)
def test_min_cov_det(): df = get_data() S = risk_models.min_cov_determinant(df, random_state=8) assert S.shape == (20, 20) assert S.index.equals(df.columns) assert S.index.equals(S.columns) assert S.notnull().all().all() # Min cov det is NOT positive semidefinite for this example. # Warning has been added to docs. # assert risk_models._is_positive_semidefinite(S) S2 = risk_models.min_cov_determinant(df, frequency=2, random_state=8) pd.testing.assert_frame_equal(S / 126, S2)
def test_min_cov_det(): df = get_data() S = risk_models.min_cov_determinant(df, random_state=8) assert S.shape == (20, 20) assert S.index.equals(df.columns) assert S.index.equals(S.columns) assert S.notnull().all().all() # assert risk_models._is_positive_semidefinite(S) # Cover that it works on np.ndarray, with a warning with pytest.warns(RuntimeWarning): S2 = risk_models.min_cov_determinant(df.to_numpy(), random_state=8) assert isinstance(S2, pd.DataFrame) np.testing.assert_equal(S.to_numpy(), S2.to_numpy())
def test_min_cov_det(): df = get_data() S = risk_models.min_cov_determinant(df, random_state=8) assert S.shape == (20, 20) assert S.index.equals(df.columns) assert S.index.equals(S.columns) assert S.notnull().all().all()