Exemplo n.º 1
0
def test_empty_histogram() :
    h = Histogram(axis=Axis(100,-50, 50))
    assert h.entries() == 0.
    assert h.sigma() == 0
    assert h.mean() == 0
    assert h.overflow() == 0
    assert h.underflow() ==0
Exemplo n.º 2
0
def test_subtract_histograms() :
    h0 = Histogram(axis=Axis(100, -50., 50.))
    weight = 0.5
    h0.fill([-49.99,49.99,-48.99,48.99], weight) # should be 0th bin
    h0.fill(0.1, 4*weight)
    h0.fill(-75., 32.)
    h0.fill(100., 55)
    h1 = Histogram(axis=Axis(100, -50., 50.))
    h1.fill([-48.99,48.99], weight) # should be 0th bin
    h1.fill(0.1, 2*weight)
    h1.fill(-101.)
    h1.fill(200.,2)
    h2 = h0 - h1
    
    assert h2.axis == h0.axis
    assert h2.entries() == h0.entries() - h1.entries()
    assert h2.overflow() == h0.overflow() - h1.overflow()
    assert h2.underflow() == h0.underflow() - h1.underflow()

    for bin in xrange(h2.axis.nbins):
        assert h2.binHeight(bin) == h0.binHeight(bin) - h1.binHeight(bin)
Exemplo n.º 3
0
def test_underflow() :
    h = Histogram(axis=Axis(100, -50., 50.))
    assert h.underflow() == 0.
    h.fill(-100.)
    assert h.underflow() == 1.