示例#1
0
def test_basic():
    m = np.logspace(10, 15, 500)
    d = dndm(m, 14.0, -1.9, 0.75, norm=1.0)

    res, _ = get_fit_curve(m, d, hs0=14.0, alpha0=-1.9, beta0=0.75, lnA0=0.0)
    print res
    assert np.all(np.isclose(res.x, np.array([14.0, -1.9, 0.75, 0.0])))
示例#2
0
def test_Arhoc():
    # Try A_rhoc
    m = np.logspace(0,17,2000)
    for i in range(100):
        ans =  simps(core.dndm(m,3*rd()+10,-1.5,0.5*rd()+0.5,norm="rhoc",Om0=0.3)*m,m)/(0.3*2.7755e11)
        err = np.abs(ans-1)
        print err
        assert np.abs(ans-1) < 1e-4
示例#3
0
def test_pdf_inf():
    """
    Test for 10 random values of the MRP parameters, whether the integral of the
    pdf is 1.
    """
    m = np.logspace(10,17,500)
    for i in range(10):
        ans =  simps(core.dndm(m,3*rd()+10,0.2*rd()-2.0,0.5*rd()+0.5,norm="pdf"),m)
        err = np.abs(ans-1)
        print err
        assert np.abs(ans-1) < 1e-4
示例#4
0
def test_0_inf():
    m = np.logspace(10, 15, 500)
    d = dndm(m, 14.0, -1.9, 0.75, norm="pdf")
    # a = _getnorm("pdf", 14.0,-1.9, 0.75,1e10, log=True)

    res, _ = get_fit_curve(
        m,
        d,
        hs0=14.5,
        alpha0=-1.8,
        beta0=0.7,
        sigma_integ=0.0,
        bounds=True,
        hs_bounds=(10, 16),
        alpha_bounds=(-1.99, -1.5),
    )
    print res
    assert np.all(np.isclose(res.x, np.array([14.0, -1.9, 0.75]), rtol=1e-3))
示例#5
0
def test_inf_0():
    m = np.logspace(10, 15, 500)
    d = dndm(m, 14.0, -1.9, 0.75, norm="rhoc")
    # a = A_rhoc(14.0,-1.9,0.75)

    res, _ = get_fit_curve(
        m,
        d,
        hs0=14.5,
        alpha0=-1.8,
        beta0=0.7,
        sigma_rhomean=0.0,
        bounds=True,
        hs_bounds=(10, 16),
        alpha_bounds=(-1.99, -1.5),
    )
    print res
    assert np.all(np.isclose(res.x, np.array([14.0, -1.9, 0.75])))