示例#1
0
def test_perturb_field_no_ic(default_user_params, redshift, perturb_field):
    """Run a perturb field without passing an init box"""
    pf = wrapper.perturb_field(redshift=redshift, user_params=default_user_params)
    assert len(pf.density) == pf.user_params.HII_DIM == default_user_params.HII_DIM
    assert pf.redshift == redshift
    assert pf.random_seed != perturb_field.random_seed
    assert not np.all(pf.density == 0)
    assert pf != perturb_field
    assert pf._seedless_repr() == perturb_field._seedless_repr()
示例#2
0
def test_pf_new_seed(perturb_field, tmpdirec):
    pf = wrapper.perturb_field(
        redshift=perturb_field.redshift,
        user_params=perturb_field.user_params,
        random_seed=1,
    )

    # we didn't write it, and this has a different seed
    assert not pf.exists(direc=tmpdirec)
    assert pf.random_seed != perturb_field.random_seed

    assert not np.all(pf.density == perturb_field.density)
示例#3
0
def test_perturb_field_ic(perturb_field, ic):
    # this will run perturb_field again, since by default regenerate=True for tests.
    # BUT it should produce exactly the same as the default perturb_field since it has
    # the same seed.
    pf = wrapper.perturb_field(redshift=perturb_field.redshift, init_boxes=ic)

    assert len(pf.density) == len(ic.lowres_density)
    assert pf.cosmo_params == ic.cosmo_params
    assert pf.user_params == ic.user_params
    assert not np.all(pf.density == 0)

    assert pf.user_params == perturb_field.user_params
    assert pf.cosmo_params == perturb_field.cosmo_params

    assert pf == perturb_field
示例#4
0
def perturb_field(ic, redshift):
    """A default perturb_field"""
    return wrapper.perturb_field(redshift=redshift, init_boxes=ic, write=True)
示例#5
0
def test_pf_unnamed_param():
    "Try using an un-named parameter"
    with pytest.raises(TypeError):
        wrapper.perturb_field(7)