def test_stdev_non_number_mean(self):
     t = [1, 1, 1]
     g = gcs.calc_stdev(t, 'ghf')
     with self.assertRaises(TypeError) as context:
         gcs.calc_stdev(t, 'bad')
     self.assertEqual(str(context.exception),
                      'Bad Argument, Requires list of numbers')
Esempio n. 2
0
 def test_stdev(self):
     self.assertAlmostEqual(get_column_stats.calc_stdev([1, 1, 1, 1, 1], 1),
                            0,
                            places=2)
     self.assertAlmostEqual(get_column_stats.calc_stdev([1, 2, 3, 4, 5], 3),
                            1.58,
                            places=2)
     self.assertAlmostEqual(get_column_stats.calc_stdev([2, 3, 9, 11, 45],
                                                        14),
                            17.75,
                            places=2)
     self.assertAlmostEqual(get_column_stats.calc_stdev([2, 2, 2, 10, 6],
                                                        4.4),
                            3.577,
                            places=2)
 def test_stdev(self):
     b = get_column_stats.calc_stdev(self)
     self.assertEqual(b, self.stdev)
 def test_stdev_full(self):
     r = gcs.calc_stdev([3, 3, 5, 5], 4)
     self.assertEqual(r, 1)
 def test_stdev_non_number_list(self):
     t = ['a', 'b', 'c']
     with self.assertRaises(TypeError) as context:
         gcs.calc_stdev(t, 1)
     self.assertEqual(str(context.exception),
                      'Bad Argument, Requires list of numbers')
 def test_stdev_null_list(self):
     with self.assertRaises(TypeError) as context:
         gcs.calc_stdev(None, 0)
     self.assertEqual(str(context.exception),
                      'Bad Argument, Requires list of numbers')
 def test_stdev_empty_args(self):
     t = []
     with self.assertRaises(ZeroDivisionError) as context:
         gcs.calc_stdev(t, None)
     self.assertEqual(str(context.exception), 'list is empty')
Esempio n. 8
0
 def test_stdev_random(self):
     exp_std = np.random.uniform(0, 100)
     dist = np.random.normal(loc=0, scale=exp_std, size=200000).tolist()
     self.assertAlmostEqual(gcs.calc_stdev(dist), exp_std, places=0)
Esempio n. 9
0
 def test_stdev_const(self):
     self.assertEqual(gcs.calc_stdev([1, 1, 1, 1, 1, 1]), 0)