Ejemplo n.º 1
0
def test_errors():
    with pytest.raises(Exception):
        Redges = [np.min(R) * 0.9, 1.6, 1.8]
        averaging.average_profile_in_bins(Redges, R, prof)
        Redges = [.6, 1.6, np.max(R) * 1.1]
        averaging.average_profile_in_bins(Redges, R, prof)
        averaging.average_profile_in_bin(np.min(R) * 0.9, 1.6, R, prof)
        averaging.average_profile_in_bin(0.6, np.max(R) * 1.1, R, prof)
Ejemplo n.º 2
0
def test_bins():
    Rbins = [[.6, 1.6], [1.6, 1.8]]
    Redges = [.6, 1.6, 1.8]
    aves = np.array([true_ave(Rlo, Rhi) for Rlo,Rhi in Rbins])
    npt.assert_array_almost_equal(aves, averaging.average_profile_in_bins(Redges, R, prof))
    arr1 = averaging.average_profile_in_bins(Redges, R, prof)
    arr2 = np.array([averaging.average_profile_in_bin(Redges[i], Redges[i+1], R, prof) for i in range(len(Redges)-1)])
    npt.assert_array_equal(arr1, arr2)
Ejemplo n.º 3
0
def test_bin():
    Rlow = .5
    Rhigh = 1.5
    npt.assert_almost_equal(
        true_ave(Rlow, Rhigh),
        averaging.average_profile_in_bin(Rlow, Rhigh, R, prof))