def test_Single(): arrout = mis.Sigma_mis_single_at_R(Rm, R, Sigma, M, c, Om, Rmis) assert len(arrout) == len(Rm) for i in range(len(Rm)): npt.assert_equal( arrout[i], mis.Sigma_mis_single_at_R(Rm[i], R, Sigma, M, c, Om, Rmis))
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, )
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))
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)