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)
Example #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)
Example #4
0
 def test_mean(self):
     file_mean = ml.list_mean(self.file_int)
     self.assertEqual(file_mean, self.direct_mean_int)
Example #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))
Example #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)
Example #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)
Example #8
0
 def test_mean_mixed_list(self):
     self.assertEqual(math_lib.list_mean(['a', 2, 'c', '4']), 3)
Example #9
0
 def test_mean_rand_ints(self):
     self.assertEqual(math_lib.list_mean(self.direct_list_mean_array),
                      self.direct_mean_val)
Example #10
0
 def test_mean_none(self):
     with self.assertRaises(ValueError):
         math_lib.list_mean(None)
Example #11
0
 def test_mean_only_str(self):
     with self.assertRaises(ValueError):
         math_lib.list_mean(['a', 'b', 'c'])
Example #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)
Example #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())
Example #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')))
Example #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))
Example #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))
Example #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)
Example #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)