Пример #1
0
def test_Sigma_mis():
    arr1 = mis.Sigma_mis_at_R(Rm, R, Sigma, M, c, Om, Rmis)
    arr2 = np.array(
        [mis.Sigma_mis_at_R(Rmi, R, Sigma, M, c, Om, Rmis) for Rmi in Rm])
    npt.assert_array_equal(arr1, arr2)
    arr1 = mis.Sigma_mis_at_R(Rm, R, Sigma, M, c, Om, Rmis, kernel='gamma')
    arr2 = np.array([
        mis.Sigma_mis_at_R(Rmi, R, Sigma, M, c, Om, Rmis, kernel='gamma')
        for Rmi in Rm
    ])
    npt.assert_array_equal(arr1, arr2)
Пример #2
0
def test_errors():
    with pytest.raises(Exception):
        mis.Sigma_mis_single_at_R(np.min(R) * 0.9, R, Sigma, M, c, Om, Rmis)
        mis.Sigma_mis_single_at_R(np.max(R) * 1.1, R, Sigma, M, c, Om, Rmis)
        mis.Sigma_mis_at_R(np.min(R) * 0.9, R, Sigma, M, c, Om, Rmis)
        mis.Sigma_mis_at_R(np.max(R) * 1.1, R, Sigma, M, c, Om, Rmis)
        mis.Sigma_mis_at_R(R, R, Sigma, M, c, Om, Rmis, kernel="blah")
        Smis = mis.Sigma_mis_at_R(R, R, Sigma, M, c, Om, Rmis) / Sigma
        mis.DeltaSigma_mis_at_R(
            np.min(R) * 0.9,
            R,
            Smis,
        )
        mis.DeltaSigma_mis_at_R(
            np.max(R) * 1.1,
            R,
            Smis,
        )
Пример #3
0
def test_DSmis():
    Smis = mis.Sigma_mis_at_R(Rm, R, Sigma, M, c, Om, Rmis)
    arrout = mis.DeltaSigma_mis_at_R(Rm, Rm, Smis)
    assert len(arrout) == len(Rm)
    for i in range(len(Rm)):
        npt.assert_equal(arrout[i], mis.DeltaSigma_mis_at_R(Rm[i], Rm, Smis))
    Smis = mis.Sigma_mis_single_at_R(Rm, R, Sigma, M, c, Om, Rmis)
    arrout = mis.DeltaSigma_mis_at_R(Rm, Rm, Smis)
    assert len(arrout) == len(Rm)
    for i in range(len(Rm)):
        npt.assert_equal(arrout[i], mis.DeltaSigma_mis_at_R(Rm[i], Rm, Smis))
Пример #4
0
def test_nomis():
    #Test what happens when Rmis=0
    Rmis = 0.0001
    lo, hi = 0, -1  #We expect the end points to be off
    dec = 3  #To this decimal place
    ones = np.ones_like(Sigma)
    Smis = mis.Sigma_mis_at_R(R, R, Sigma, M, c, Om, Rmis) / Sigma
    #npt.assert_array_almost_equal(Sigma[lo:hi], Smis[lo:hi], decimal=dec)
    npt.assert_array_almost_equal(ones[lo:hi], Smis[lo:hi], decimal=dec)
    Smis = mis.Sigma_mis_single_at_R(R, R, Sigma, M, c, Om, Rmis) / Sigma
    #npt.assert_array_almost_equal(Sigma[lo:hi], Smis[lo:hi], decimal=dec)
    npt.assert_array_almost_equal(ones[lo:hi], Smis[lo:hi], decimal=dec)