예제 #1
0
def check_power(cosmo):
    """
    Check that power spectrum and sigma functions can be run.
    """
    # Types of scale factor
    a = 0.9
    a_arr = np.linspace(0.2, 1., 5)

    # Types of wavenumber input (scalar, list, array)
    k_scl = 1e-1
    k_lst = [1e-4, 1e-3, 1e-2, 1e-1, 1e0]
    k_arr = np.logspace(-4., 0., 5)

    # Types of smoothing scale, R
    R_scl = 8.
    R_lst = [1., 5., 10., 20., 50., 100.]
    R_arr = np.array([1., 5., 10., 20., 50., 100.])

    # linear_matter_power
    assert_(all_finite(ccl.linear_matter_power(cosmo, k_scl, a)))
    assert_(all_finite(ccl.linear_matter_power(cosmo, k_lst, a)))
    assert_(all_finite(ccl.linear_matter_power(cosmo, k_arr, a)))

    assert_raises(TypeError, ccl.linear_matter_power, cosmo, k_scl, a_arr)
    assert_raises(TypeError, ccl.linear_matter_power, cosmo, k_lst, a_arr)
    assert_raises(TypeError, ccl.linear_matter_power, cosmo, k_arr, a_arr)

    # nonlin_matter_power
    assert_(all_finite(ccl.nonlin_matter_power(cosmo, k_scl, a)))
    assert_(all_finite(ccl.nonlin_matter_power(cosmo, k_lst, a)))
    assert_(all_finite(ccl.nonlin_matter_power(cosmo, k_arr, a)))

    assert_raises(TypeError, ccl.nonlin_matter_power, cosmo, k_scl, a_arr)
    assert_raises(TypeError, ccl.nonlin_matter_power, cosmo, k_lst, a_arr)
    assert_raises(TypeError, ccl.nonlin_matter_power, cosmo, k_arr, a_arr)

    # sigmaR
    assert_(all_finite(ccl.sigmaR(cosmo, R_scl)))
    assert_(all_finite(ccl.sigmaR(cosmo, R_lst)))
    assert_(all_finite(ccl.sigmaR(cosmo, R_arr)))

    # sigmaV
    assert_(all_finite(ccl.sigmaV(cosmo, R_scl)))
    assert_(all_finite(ccl.sigmaV(cosmo, R_lst)))
    assert_(all_finite(ccl.sigmaV(cosmo, R_arr)))

    # sigma8
    assert_(all_finite(ccl.sigma8(cosmo)))
예제 #2
0
파일: test_power.py 프로젝트: LSSTDESC/CCL
def test_sigmaV_smoke(r):
    a = 0.8
    sig = ccl.sigmaV(COSMO, r, a)
    assert np.all(np.isfinite(sig))
    assert np.shape(sig) == np.shape(r)