def test_list_mean_const(self):
     """This function tests if list_mean gives correct
     result given a list of constants.
     """
     r = math_lib.list_mean([1, 1, 1, 1])
     self.assertEqual(r, 1)
Exemple #2
0
 def test_list_stdev_empty_list(self):
     self.assertIsNone(ml.list_mean([]), None)
 def test_list_mean_empty_list(self):
     r = math_lib.list_mean(None)
     self.assertEqual(r, None)
Exemple #4
0
 def test_mean(self):
     file_mean = ml.list_mean(self.file_int)
     self.assertEqual(file_mean, self.direct_mean_int)
Exemple #5
0
 def test_list_mean_random_int_list(self):
     for i in range(100):
         L = []
         for j in range(10):
             L.append(random.randint(0, 100))
         self.assertEqual(ml.list_mean(L), statistics.mean(L))
Exemple #6
0
 def test_mean_with_NaNs(self):
     bad_file = [2, 2, 2, 2, 2, 2, 'NaN']
     with self.assertRaises(TypeError):
         ml.list_mean(bad_file)
Exemple #7
0
 def test_mean_with_non_int(self):
     bad_file = [2, 2, 'q', 2, 'a', 2]
     with self.assertRaises(TypeError):
         ml.list_mean(bad_file)
Exemple #8
0
 def test_mean_mixed_list(self):
     self.assertEqual(math_lib.list_mean(['a', 2, 'c', '4']), 3)
Exemple #9
0
 def test_mean_rand_ints(self):
     self.assertEqual(math_lib.list_mean(self.direct_list_mean_array),
                      self.direct_mean_val)
Exemple #10
0
 def test_mean_none(self):
     with self.assertRaises(ValueError):
         math_lib.list_mean(None)
Exemple #11
0
 def test_mean_only_str(self):
     with self.assertRaises(ValueError):
         math_lib.list_mean(['a', 'b', 'c'])
Exemple #12
0
 def test_mean_empty(self):
     with self.assertRaises(ValueError):
         math_lib.list_mean([])
 def test_list_mean_empty(self):
     """This function tests if the input list is empty
     """
     r = math_lib.list_mean(None)
     self.assertEqual(r, None)
 def test_list_mean_exceptions(self):
     """This function tests if an exception is handled properly
     """
     with self.assertRaises(TypeError) as ex:
         math_lib.list_mean([1, 1, 1, 'x'])
     self.assertTrue('Unsupported value in the list' in str(ex.exception))
 def test_mean_empty_array(self):
     self.assertEqual(math_lib.list_mean([]), None)
    def test_mean_letter_array(self):

        self.assertRaises(ValueError,
                          lambda: math_lib.list_mean(['A', 'B', 'C']))
 def test_mean_ones_array(self):
     self.assertEqual(math_lib.list_mean([1, 1, 1, 1]), 1)
 def test_mean_none(self):
     self.assertEqual(math_lib.list_mean(None), None)
Exemple #19
0
 def test_mean_with_no_entries(self):
     bad_file = []
     with self.assertRaises(ZeroDivisionError):
         ml.list_mean(bad_file)
 def test_mean_null(self):
     self.assertRaises(TypeError, lambda: math_lib.list_mean())
Exemple #21
0
 def test_mean_with_unstructured_entries(self):
     bad_file = ['a', 'b', 'c']
     with self.assertRaises(TypeError):
         ml.list_mean(bad_file)
 def test_mean_string(self):
     self.assertRaises(TypeError, lambda: math_lib.list_mean(str('hi')))
Exemple #23
0
 def test_list_mean_one_list(self):
     self.assertEqual(ml.list_mean([1, 1, 1, 1, 1]), 1)
 def test_mean_int(self):
     self.assertRaises(TypeError, lambda: math_lib.list_mean(4))
Exemple #25
0
 def test_list_mean_random_float_list(self):
     for i in range(100):
         L = []
         for j in range(10):
             L.append(random.uniform(0, 100))
         self.assertAlmostEqual(ml.list_mean(L), statistics.mean(L))
 def test_mean_float(self):
     self.assertRaises(TypeError, lambda: math_lib.list_mean(420.69))
Exemple #27
0
 def test_list_mean_none(self):
     self.assertIsNone(ml.list_mean(None), None)
 def test_mean_Boolean(self):
     self.assertRaises(TypeError, lambda: math_lib.list_mean(True))
 def test_mean_constants(self):
     r = math_lib.list_mean([1, 1, 1, 1])
     self.assertEqual(r, 1)
Exemple #30
0
 def test_float_static_list(self):
     self.assertAlmostEqual(math_lib.list_mean(self.float_static_list),
                            statistics.mean(self.float_static_list), 5)
     self.assertAlmostEqual(math_lib.list_stdev(self.float_static_list),
                            statistics.stdev(self.float_static_list), 5)