Exemple #1
0
 def test_std(self):
     self.assertEqual(get_column_stats.get_std([1, 2, 3, 4, 5]),
                      statistics.pstdev([1, 2, 3, 4, 5]))
     self.assertEqual(get_column_stats.get_std([0, 0, 0, 0, 0]),
                      statistics.pstdev([0, 0, 0, 0, 0]))
     self.assertEqual(get_column_stats.get_std([-1, -2, -3, -4, -5]),
                      statistics.pstdev([-1, -2, -3, -4, -5]))
Exemple #2
0
 def test_stdev_file(self):
     V = []
     f = open(self.test_file_name, 'r')
     for l in f:
         A = [int(x) for x in l.split()]
         V.append(A[int(0)])
     self.assertEqual(round(get_column_stats.get_std(A), 5),
                      round(statistics.pstdev(A, statistics.mean(A)), 5))
     f.close()
Exemple #3
0
 def test_stdev_file_loop(self):
     for i in range(100):
         self.setUp()
         V = []
         f = open(self.test_file_name, 'r')
         for l in f:
             A = [int(x) for x in l.split()]
             V.append(A[int(0)])
         self.assertEqual(round(get_column_stats.get_std(V), 5),
                          round(statistics.pstdev(V), 5))
         f.close()
Exemple #4
0
 def test_stdev(self):
     A = [random.randint(0, 1000)
          for i in range(random.randint(0, 100))]
     self.assertEqual(round(get_column_stats.get_std(A), 5),
                      round(statistics.pstdev(A, statistics.mean(A)), 5))
Exemple #5
0
 def test_string_stdev(self):
     self.assertRaises(TypeError,
                       lambda: get_column_stats.get_std('hello'))
Exemple #6
0
 def test_null_stdev(self):
     self.assertRaises(TypeError,
                       lambda: get_column_stats.get_std())
Exemple #7
0
 def test_empty_stdev(self):
     self.assertRaises(ZeroDivisionError,
                       lambda: get_column_stats.get_std([]))