示例#1
0
 def testAddExponentialBins(self):
     b = histogram.HistogramBinBoundaries(0.5)
     b.AddExponentialBins(8, 4)
     self._CheckBoundaries(b, 0.5, 8, [
         histogram.Range.FromExplicitRange(-histogram.JS_MAX_VALUE, 0.5),
         histogram.Range.FromExplicitRange(0.5, 1),
         histogram.Range.FromExplicitRange(1, 2),
         histogram.Range.FromExplicitRange(2, 4),
         histogram.Range.FromExplicitRange(4, 8),
         histogram.Range.FromExplicitRange(8, histogram.JS_MAX_VALUE),
     ])
示例#2
0
 def testBinBoundariesRaises(self):
     b = histogram.HistogramBinBoundaries(-7)
     with self.assertRaises(Exception):
         b.AddBinBoundary(-10)
     with self.assertRaises(Exception):
         b.AddBinBoundary(-7)
     with self.assertRaises(Exception):
         b.AddLinearBins(-10, 10)
     with self.assertRaises(Exception):
         b.AddLinearBins(-7, 10)
     with self.assertRaises(Exception):
         b.AddLinearBins(10, 0)
     with self.assertRaises(Exception):
         b.AddExponentialBins(16, 4)
     b = histogram.HistogramBinBoundaries(8)
     with self.assertRaises(Exception):
         b.AddExponentialBins(20, 0)
     with self.assertRaises(Exception):
         b.AddExponentialBins(5, 3)
     with self.assertRaises(Exception):
         b.AddExponentialBins(8, 3)
示例#3
0
 def testAddLinearBins(self):
     b = histogram.HistogramBinBoundaries(1000)
     b.AddLinearBins(1200, 5)
     self._CheckBoundaries(b, 1000, 1200, [
         histogram.Range.FromExplicitRange(-histogram.JS_MAX_VALUE, 1000),
         histogram.Range.FromExplicitRange(1000, 1040),
         histogram.Range.FromExplicitRange(1040, 1080),
         histogram.Range.FromExplicitRange(1080, 1120),
         histogram.Range.FromExplicitRange(1120, 1160),
         histogram.Range.FromExplicitRange(1160, 1200),
         histogram.Range.FromExplicitRange(1200, histogram.JS_MAX_VALUE),
     ])
示例#4
0
    def testAddBinBoundary(self):
        b = histogram.HistogramBinBoundaries(-100)
        b.AddBinBoundary(50)
        self._CheckBoundaries(b, -100, 50, [
            histogram.Range.FromExplicitRange(-histogram.JS_MAX_VALUE, -100),
            histogram.Range.FromExplicitRange(-100, 50),
            histogram.Range.FromExplicitRange(50, histogram.JS_MAX_VALUE),
        ])

        b.AddBinBoundary(60)
        b.AddBinBoundary(75)
        self._CheckBoundaries(b, -100, 75, [
            histogram.Range.FromExplicitRange(-histogram.JS_MAX_VALUE, -100),
            histogram.Range.FromExplicitRange(-100, 50),
            histogram.Range.FromExplicitRange(50, 60),
            histogram.Range.FromExplicitRange(60, 75),
            histogram.Range.FromExplicitRange(75, histogram.JS_MAX_VALUE),
        ])
示例#5
0
  def testBinBoundariesCombined(self):
    b = histogram.HistogramBinBoundaries(-273.15)
    b.AddBinBoundary(-50)
    b.AddLinearBins(4, 3)
    b.AddExponentialBins(16, 2)
    b.AddLinearBins(17, 4)
    b.AddBinBoundary(100)

    self._CheckBoundaries(b, -273.15, 100, [
        histogram.Range.FromExplicitRange(-histogram.JS_MAX_VALUE, -273.15),
        histogram.Range.FromExplicitRange(-273.15, -50),
        histogram.Range.FromExplicitRange(-50, -32),
        histogram.Range.FromExplicitRange(-32, -14),
        histogram.Range.FromExplicitRange(-14, 4),
        histogram.Range.FromExplicitRange(4, 8),
        histogram.Range.FromExplicitRange(8, 16),
        histogram.Range.FromExplicitRange(16, 16.25),
        histogram.Range.FromExplicitRange(16.25, 16.5),
        histogram.Range.FromExplicitRange(16.5, 16.75),
        histogram.Range.FromExplicitRange(16.75, 17),
        histogram.Range.FromExplicitRange(17, 100),
        histogram.Range.FromExplicitRange(100, histogram.JS_MAX_VALUE)
    ])