def test_calculate(self): actual = mean_var_std.calculate([2, 6, 2, 8, 4, 0, 1, 5, 7]) expected = { "mean": [ [3.6666666666666665, 5.0, 3.0], [3.3333333333333335, 4.0, 4.333333333333333], 3.888888888888889, ], "variance": [ [9.555555555555557, 0.6666666666666666, 8.666666666666666], [3.555555555555556, 10.666666666666666, 6.222222222222221], 6.987654320987654, ], "standard deviation": [ [3.091206165165235, 0.816496580927726, 2.943920288775949], [1.8856180831641267, 3.265986323710904, 2.494438257849294], 2.6434171674156266, ], "max": [[8, 6, 7], [6, 8, 7], 8], "min": [[1, 4, 0], [2, 0, 1], 0], "sum": [[11, 15, 9], [10, 12, 13], 35], } # noqa: 501 self.assertAlmostEqual( actual, expected, "Expected different output when calling " "'calculate()' with '[2,6,2,8,4,0,1,5,7]'", )
def test_calculate2(self): actual = mean_var_std.calculate([9, 1, 5, 3, 3, 3, 2, 9, 0]) expected = { "mean": [ [4.666666666666667, 4.333333333333333, 2.6666666666666665], [5.0, 3.0, 3.6666666666666665], 3.888888888888889, ], "variance": [ [9.555555555555555, 11.555555555555557, 4.222222222222222], [10.666666666666666, 0.0, 14.888888888888891], 9.209876543209875, ], "standard deviation": [ [3.0912061651652345, 3.39934634239519, 2.0548046676563256], [3.265986323710904, 0.0, 3.8586123009300755], 3.0347778408328137, ], "max": [[9, 9, 5], [9, 3, 9], 9], "min": [[2, 1, 0], [1, 3, 0], 0], "sum": [[14, 13, 8], [15, 9, 11], 35], } self.assertAlmostEqual( actual, expected, "Expected different output when calling " "'calculate()' with '[9,1,5,3,3,3,2,9,0]'", )
def test_calculate2(self): self.maxDiff = None actual = mean_var_std.calculate([9, 1, 5, 3, 3, 3, 2, 9, 0]) expected = { 'mean': [[4.666666666666667, 4.333333333333333, 2.6666666666666665], [5.0, 3.0, 3.6666666666666665], 3.888888888888889], 'variance': [[9.555555555555555, 11.555555555555557, 4.222222222222222], [10.666666666666666, 0.0, 14.888888888888891], 9.209876543209877], 'standard deviation': [[3.0912061651652345, 3.39934634239519, 2.0548046676563256], [3.265986323710904, 0.0, 3.8586123009300755], 3.034777840832814], 'max': [[9, 9, 5], [9, 3, 9], 9], 'min': [[2, 1, 0], [1, 3, 0], 0], 'sum': [[14, 13, 8], [15, 9, 11], 35] } self.assertDictEqual( actual, expected, "Expected different output when calling 'calculate()' with '[9,1,5,3,3,3,2,9,0]'" )
def test_calculate(self): self.maxDiff = None actual = mean_var_std.calculate([2, 6, 2, 8, 4, 0, 1, 5, 7]) expected = { 'mean': [[3.6666666666666665, 5.0, 3.0], [3.3333333333333335, 4.0, 4.333333333333333], 3.888888888888889], 'variance': [[9.555555555555557, 0.6666666666666666, 8.666666666666666], [3.555555555555556, 10.666666666666666, 6.222222222222221], 6.987654320987653], 'standard deviation': [[3.091206165165235, 0.816496580927726, 2.943920288775949], [1.8856180831641267, 3.265986323710904, 2.494438257849294], 2.643417167415626], 'max': [[8, 6, 7], [6, 8, 7], 8], 'min': [[1, 4, 0], [2, 0, 1], 0], 'sum': [[11, 15, 9], [10, 12, 13], 35] } self.assertDictEqual( actual, expected, "Expected different output when calling 'calculate()' with '[2,6,2,8,4,0,1,5,7]'" )
# This entrypoint file to be used in development. Start by reading README.md import mean_var_std from unittest import main print(mean_var_std.calculate([0, 1, 2, 3, 4, 5, 6, 7, 8])) # Run unit tests automatically # In the original test_module.py, assertAlmostEqual() was used but it can't # compare dictionaries. So, i changed the function with assertDictEqual(). main(module='test_module', exit=False)
# This entrypoint file to be used in development. Start by reading README.md import mean_var_std from unittest import main print(mean_var_std.calculate([2, 6, 2, 8, 4, 0, 1, 5, 7])) # Run unit tests automatically main(module='test_module', exit=False)
# This entrypoint file to be used in development. Start by reading README.md import mean_var_std from unittest import main a = mean_var_std.calculate([2, 6, 2, 8, 4, 0, 1, 5, 7]) print(mean_var_std.calculate([0, 1, 2, 3, 4, 5, 6, 7, 8])) # Run unit tests automatically main(module='test_module', exit=False) dictlist = list() for key, value in a.items(): temp = [key, value] dictlist.append(temp) a.items() print(a)