Exemple #1
0
def test_power():
    h = Hist2D(10, 0, 1, 10, 0, 1)
    h.FillRandom(F2('x+y'))
    p = h.Clone()
    p /= h.Integral()
    pow(h, 2)
    h**2
    h**p
    assert_raises(ValueError, pow, h, Hist2D(20, 0, 1, 10, 0, 1))
    assert_raises(TypeError, pow, h, Hist(10, 0, 1))
    h **= 2
Exemple #2
0
def test_quantiles():
    h3d = Hist3D(10, 0, 1, 10, 0, 1, 10, 0, 1)
    h3d.FillRandom('gaus')
    h3d.quantiles(2)
    h3d.quantiles(2, axis=1)
    h3d.quantiles([0, .5, 1], axis=2)

    h2d = Hist2D(100, 0, 1, 100, 0, 1)
    h2d.FillRandom(F2('x+y'))
    h2d.quantiles(4, axis=0)
    h2d.quantiles(4, axis=1)
Exemple #3
0
def test_integral_error():
    h = Hist(1, 0, 1)
    h.FillRandom('gaus')
    ref_integral, ref_error = h.integral(error=True)

    h1 = Hist(10, 0, 1)
    h1.FillRandom('gaus')
    integral, error = h1.integral(error=True)
    assert_almost_equal(integral, ref_integral)
    assert_almost_equal(error, ref_error)

    h2 = Hist2D(10, 0, 1, 10, 0, 1)
    h2.FillRandom(F2('x+y'))
    integral, error = h2.integral(error=True)
    assert_almost_equal(integral, ref_integral)
    assert_almost_equal(error, ref_error)

    h3 = Hist3D(10, 0, 1, 10, 0, 1, 10, 0, 1)
    h3.FillRandom(F3('x+y+z'))
    integral, error = h3.integral(error=True)
    assert_almost_equal(integral, ref_integral)
    assert_almost_equal(error, ref_error)