def test_eisenstein_hu():
    ' Test Eisenstein & Hu Linear matter power spectrum with\n    and without wiggles using astropy default cosmology'
    cosmology = default_cosmology.get()
    A_s = 2.1982e-09
    n_s = 0.969453
    kwmap = 0.02
    scalar_input = 1
    scalar_output_w = power_spectrum(scalar_input, A_s, n_s, cosmology, kwmap, wiggle=True)
    scalar_output_nw = power_spectrum(scalar_input, A_s, n_s, cosmology, kwmap, wiggle=False)
    assert np.isscalar(scalar_output_w)
    assert np.isscalar(scalar_output_nw)
    array_shape = (10,)
    array_input = np.random.uniform(size=array_shape)
    array_output_w = power_spectrum(array_input, A_s, n_s, cosmology, kwmap, wiggle=True)
    array_output_nw = power_spectrum(array_input, A_s, n_s, cosmology, kwmap, wiggle=False)
    assert (array_output_w.shape == array_shape)
    assert (array_output_nw.shape == array_shape)
    wavenumber = np.logspace((- 3), 1, num=5, base=10.0)
    pk_eisensteinhu_w = power_spectrum(wavenumber, A_s, n_s, cosmology, kwmap, wiggle=True)
    pk_eisensteinhu_nw = power_spectrum(wavenumber, A_s, n_s, cosmology, kwmap, wiggle=False)
    pk_cosmosis_w = np.array([6474.60158, 37161.0099, 9657.02614, 114.604456, 0.391399918])
    pk_cosmosis_nw = np.array([6472.186, 37733.0704, 10006.2077, 113.08298, 0.383094714])
    assert np.allclose(pk_eisensteinhu_w, pk_cosmosis_w)
    assert np.allclose(pk_eisensteinhu_nw, pk_cosmosis_nw)
    negative_wavenumber_scalar = 0
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_scalar, A_s, n_s, cosmology, kwmap, wiggle=True)
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_scalar, A_s, n_s, cosmology, kwmap, wiggle=False)
    negative_wavenumber_array = [0, 1, (- 2), 3]
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_array, A_s, n_s, cosmology, kwmap, wiggle=True)
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_array, A_s, n_s, cosmology, kwmap, wiggle=False)
Test Eisenstein & Hu Linear matter power spectrum with
and without wiggles using astropy default cosmology
def test_eisenstein_hu():
    ' Test Eisenstein & Hu Linear matter power spectrum with\n    and without wiggles using astropy default cosmology'
    cosmology = default_cosmology.get()
    A_s = 2.1982e-09
    n_s = 0.969453
    kwmap = 0.02
    scalar_input = 1
    scalar_output_w = power_spectrum(scalar_input, A_s, n_s, cosmology, kwmap, wiggle=True)
    scalar_output_nw = power_spectrum(scalar_input, A_s, n_s, cosmology, kwmap, wiggle=False)
    assert np.isscalar(scalar_output_w)
    assert np.isscalar(scalar_output_nw)
    array_shape = (10,)
    array_input = np.random.uniform(size=array_shape)
    array_output_w = power_spectrum(array_input, A_s, n_s, cosmology, kwmap, wiggle=True)
    array_output_nw = power_spectrum(array_input, A_s, n_s, cosmology, kwmap, wiggle=False)
    assert (array_output_w.shape == array_shape)
    assert (array_output_nw.shape == array_shape)
    wavenumber = np.logspace((- 3), 1, num=5, base=10.0)
    pk_eisensteinhu_w = power_spectrum(wavenumber, A_s, n_s, cosmology, kwmap, wiggle=True)
    pk_eisensteinhu_nw = power_spectrum(wavenumber, A_s, n_s, cosmology, kwmap, wiggle=False)
    pk_cosmosis_w = np.array([6474.60158, 37161.0099, 9657.02614, 114.604456, 0.391399918])
    pk_cosmosis_nw = np.array([6472.186, 37733.0704, 10006.2077, 113.08298, 0.383094714])
    assert np.allclose(pk_eisensteinhu_w, pk_cosmosis_w)
    assert np.allclose(pk_eisensteinhu_nw, pk_cosmosis_nw)
    negative_wavenumber_scalar = 0
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_scalar, A_s, n_s, cosmology, kwmap, wiggle=True)
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_scalar, A_s, n_s, cosmology, kwmap, wiggle=False)
    negative_wavenumber_array = [0, 1, (- 2), 3]
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_array, A_s, n_s, cosmology, kwmap, wiggle=True)
    with pytest.raises(ValueError):
        power_spectrum(negative_wavenumber_array, A_s, n_s, cosmology, kwmap, wiggle=False)