def test_spd_inv_sqrt(spd_matrix, epsilon, method, return_rank): M = spd_inv_sqrt(spd_matrix, epsilon=epsilon, method=method, return_rank=return_rank) if return_rank: rank = M[1] M = M[0] assert_equal(rank, 3) assert_array_almost_equal(M @ M.T, spd_inv(spd_matrix))
def test_spd_inv_sqrt_1d(): W = np.array([[.5]]) assert_almost_equal(spd_inv_sqrt(W).squeeze(), 1. / np.sqrt(.5)) with assert_raises(ZeroRankError): spd_inv_sqrt(np.array([[.001]]), epsilon=.01)