Esempio n. 1
0
 def test_avg_is_nan_for_empty_input(self):
     computedStats = statistics.calculateStats([])
     # All fields of computedStats (average, max, min) must be
     # nan (not-a-number), as defined in the math package
     # Design the assert here.
     # Use nan and isnan in https://docs.python.org/3/library/math.html
     self.assertTrue(computedStats["avg"], math.nan)
 def test_avg_is_nan_for_empty_input(self):
     computedStats = statistics.calculateStats([])
     # All fields of computedStats (average, max, min) must be
     # nan (not-a-number), as defined in the math package
     # Design the assert here.
     self.assertTrue(math.isnan(computedStats["avg"]))
     self.assertTrue(math.isnan(computedStats["max"]))
     self.assertTrue(math.isnan(computedStats["min"]))
Esempio n. 3
0
 def test_avg_is_nan_for_empty_input(self):
   computedStats = statistics.calculateStats([])
   # All fields of computedStats (average, max, min) must be
   # nan (not-a-number), as defined in the math package
   # Design the assert here.
   self.assertIs(computedStats["avg"], math.nan, 'mean requires at least one data point')
   self.assertIs(computedStats["max"], math.nan)
   self.assertIs(computedStats["min"], math.nan)
Esempio n. 4
0
 def test_report_min_max_avg(self):
     computedStats = statistics.calculateStats([1.5, 8.9, 3.2, 4.5])
     epsilon = 0.001
     self.assertAlmostEqual(computedStats["avg"], 4.525, delta=epsilon)
     self.assertAlmostEqual(computedStats["max"], 8.9, delta=epsilon)
     self.assertAlmostEqual(computedStats["min"], 1.5, delta=epsilon)
Esempio n. 5
0
 def test_avg_is_nan_for_empty_input(self):
     computedStats = statistics.calculateStats([])
     #    print('max1:',computedStats["max"])
     self.assertTrue(math.isnan(computedStats["avg"]))
     self.assertTrue(math.isnan(computedStats["max"]))
     self.assertTrue(math.isnan(computedStats["min"]))
Esempio n. 6
0
 def test_avg_is_nan_for_empty_input(self):
   computedStats = statistics.calculateStats([])
Esempio n. 7
0
 def checkAndAlert(self, numbers):
     computedStats = statistics.calculateStats(numbers)
     if computedStats["max"] > self.maxThreshold:
         for obj in self.alertObjects:
             obj.trigger()