def test_cl2cov_log_shift_err(): """Test that cl2cov raises an exception when log covariance is requested but no shift is specified.""" nside = 16 cl = [0] with np.testing.assert_raises_regex(Exception, 'Shift'): cov.cl2cov_mat(cl, nside, log=True)
def test_cl2cov_cl_dim(): """Test that cl2cov raises an exception when cl is a not a 1D array.""" nside = 16 cl = np.zeros((10, 10)) with np.testing.assert_raises_regex(Exception, '1D'): cov.cl2cov_mat(cl, nside)
def test_cl2cov_indices_unique(): """Test that cl2cov raises an exception when indices is not unique.""" nside = 16 cl = np.zeros(10) inds = [0, 0] with np.testing.assert_raises_regex(Exception, 'unique'): cov.cl2cov_mat(cl, nside, indices=inds)
def test_cl2cov_indices_dim(): """Test that cl2cov raises an exception when indices is a not a 1D array.""" nside = 16 cl = np.zeros(10) inds = np.arange(100).reshape([10, -1]) with np.testing.assert_raises_regex(Exception, '1D'): cov.cl2cov_mat(cl, nside, indices=inds)
def test_cl2cov_truncate(): """Test that cl2cov will truncate l modes greater than lmax=0 and will return monopole results.""" nside = 4 cl = np.ones(1000) cov_mat = cov.cl2cov_mat(cl, nside, lmax=0) np.testing.assert_almost_equal(cov_mat, cov_mat[0, 0])
def test_cl2cov_zero(): """Test that covariance matrix is all zeros when power spectrum is zero.""" nside = 4 cl = np.zeros(1000) cov_mat = cov.cl2cov_mat(cl, nside) np.testing.assert_almost_equal(cov_mat, 0)
def test_cl2cov_monopole(): """Test that covariance matrix is constant with monopole power spectrum.""" nside = 4 cl = np.zeros(1000) cl[0] = 1 cov_mat = cov.cl2cov_mat(cl, nside) np.testing.assert_almost_equal(cov_mat, cov_mat[0, 0])
def test_cl2cov_log(): """Test that cl2cov raises an exception when log covariance is requested but no shift is specified.""" nside = 16 cl = [1] xi_ii = cov.cl2xi_theta(cl, 0) cov_mat = cov.cl2cov_mat(cl, nside, log=True, shift=1) np.testing.assert_almost_equal(cov_mat, np.log(xi_ii + 1))
def test_cl2cov_dipole(): """Test that covariance matrix has opposite signs at poles with dipole power spectrum.""" nside = 4 cl = np.zeros(1000) cl[1] = 1 cov_mat = cov.cl2cov_mat(cl, nside) # Using the second to last pixel for antipodal point due to geometry of Healpix. np.testing.assert_almost_equal(cov_mat[0, 0], -cov_mat[0, -2])