示例#1
0
def check_massfunc(cosmo):
    """
    Check that mass function and supporting functions can be run.
    """

    z = 0.
    z_arr = np.linspace(0., 2., 10)
    a = 1.
    a_arr = 1. / (1. + z_arr)
    mhalo_scl = 1e13
    mhalo_lst = [1e11, 1e12, 1e13, 1e14, 1e15, 1e16]
    mhalo_arr = np.array([1e11, 1e12, 1e13, 1e14, 1e15, 1e16])
    odelta = 200.

    # massfunc
    assert_(all_finite(ccl.massfunc(cosmo, mhalo_scl, a, odelta)))
    assert_(all_finite(ccl.massfunc(cosmo, mhalo_lst, a, odelta)))
    assert_(all_finite(ccl.massfunc(cosmo, mhalo_arr, a, odelta)))

    assert_raises(TypeError, ccl.massfunc, cosmo, mhalo_scl, a_arr, odelta)
    assert_raises(TypeError, ccl.massfunc, cosmo, mhalo_lst, a_arr, odelta)
    assert_raises(TypeError, ccl.massfunc, cosmo, mhalo_arr, a_arr, odelta)

    # Check whether odelta out of bounds
    assert_raises(CCLError, ccl.massfunc, cosmo, mhalo_scl, a, 199.)
    assert_raises(CCLError, ccl.massfunc, cosmo, mhalo_scl, a, 5000.)

    # massfunc_m2r
    assert_(all_finite(ccl.massfunc_m2r(cosmo, mhalo_scl)))
    assert_(all_finite(ccl.massfunc_m2r(cosmo, mhalo_lst)))
    assert_(all_finite(ccl.massfunc_m2r(cosmo, mhalo_arr)))

    # sigmaM
    assert_(all_finite(ccl.sigmaM(cosmo, mhalo_scl, a)))
    assert_(all_finite(ccl.sigmaM(cosmo, mhalo_lst, a)))
    assert_(all_finite(ccl.sigmaM(cosmo, mhalo_arr, a)))

    assert_raises(TypeError, ccl.sigmaM, cosmo, mhalo_scl, a_arr)
    assert_raises(TypeError, ccl.sigmaM, cosmo, mhalo_lst, a_arr)
    assert_raises(TypeError, ccl.sigmaM, cosmo, mhalo_arr, a_arr)

    # halo_bias
    assert_(all_finite(ccl.halo_bias(cosmo, mhalo_scl, a)))
    assert_(all_finite(ccl.halo_bias(cosmo, mhalo_lst, a)))
    assert_(all_finite(ccl.halo_bias(cosmo, mhalo_arr, a)))
示例#2
0
def test_massfunc_m2r_smoke(m):
    r = ccl.massfunc_m2r(COSMO, m)
    assert np.all(np.isfinite(r))
    assert np.shape(r) == np.shape(m)