Example #1
0
    def test_describe(self):
        r1 = re.compile(r'\d+[:]-?\d+[.]\d*[<][=]\d+[.]?\d*[<]-?\d+[.]\d*')
        r2 = re.compile(r'-?\d+[.]?(\d+)?')
        hist = hogc.Histogram1fi(9, -4.5, 4.5)
        desc =  hogc.describeHistogram1fi(hist, verbose=True)
        self.assertTrue(type(desc), type(""))
        self.assertEqual(len(desc.split(",")[1:-1]), 9)
        for i in desc.split(",")[1:-1]:
            self.assertTrue(r1.match(i.strip()) != None)

        desc =  hogc.describeHistogram1fi(hist, verbose=False)
        self.assertEqual(len(desc.split(",")[:]), 9)
        for i in desc.split(","):
            self.assertTrue(r2.match(i.strip()) != None)
        pass
Example #2
0
    def test_addSamples2(self):
        hist = hogc.Histogram1fi(9, -4.5, 4.5)
        #add border bin value, this shoud land in the second bin (ie bin indexed 1)
        hist.addSample(4.5)
        self.assertEqual(hist.nSamples, 1)
        histData = hist.hist()

        for i in range(2, hist.nBins-1):
            self.assertEqual(histData[i], 0)
        self.assertEqual(histData[hist.nBins-1], 1)
        histData[3] = 10
        desc =  hogc.describeHistogram1fi(hist, verbose=True)
        print "histogra, desc: ", desc
        pass