Beispiel #1
0
 def test_mean_calculator(self):
     self.statistics = Statistics()
     self.test_data = csv_reader2('src/Tests/StatisticsTests/data/mean.csv')
     result = 3
     for row in self.test_data:
         self.assertEqual(self.statistics.mean(row), result)
         self.assertEqual(self.statistics.result, int(result))
         self.assertRaises(ZeroDivisionError, self.statistics.mean([]))
         self.assertRaises(ValueError, self.statistics.mean(['one', 'two']))
    def test_p_value_calculator(self):
        self.statistics = Statistics()
        self.test_data = CsvReader(
            'src/Tests/StatisticsTests/data/p_value.csv').data

        for row in self.test_data:
            self.assertEqual(
                self.statistics.p_value(row['EVENT'], row['SAMPLES']),
                float(row['RESULT']))
            self.assertEqual(self.statistics.result, float(row['RESULT']))
    def test_proportion_calculator(self):
        self.statistics = Statistics()
        self.test_data = CsvReader(
            'src/Tests/StatisticsTests/data/proportion.csv').data

        for row in self.test_data:
            self.assertEqual(
                self.statistics.get_proportion(row['SAMPLE SIZE'],
                                               row['OUTCOMES']),
                float(row['RESULT']))
            self.assertEqual(self.statistics.result, float(row['RESULT']))
    def test_sample_mean_calculator(self):
        self.statistics = Statistics()
        self.test_data = csv_reader2('src/Tests/StatisticsTests/data/mean.csv')

        for row in self.test_data:
            # check that get sample returns the proper number of samples
            self.assertEqual(len(get_sample(row, 3)), 3)

            # check that sample size is not 0
            self.assertRaises(ZeroDivisionError,
                              self.statistics.sample_mean([], 0))

        #   Test sample is not larger than population
        self.assertRaises(ValueError, self.statistics.sample_mean([1, 2, 3],
                                                                  4))
class MyTestCase(unittest.TestCase):
    def tearDown(self):
        if CsvReader.data is not None:
            CsvReader.data = []

    def test_p_value_calculator(self):
        self.statistics = Statistics()
        self.test_data = CsvReader(
            'src/Tests/StatisticsTests/data/p_value.csv').data

        for row in self.test_data:
            self.assertEqual(
                self.statistics.p_value(row['EVENT'], row['SAMPLES']),
                float(row['RESULT']))
            self.assertEqual(self.statistics.result, float(row['RESULT']))
class MyTestCase(unittest.TestCase):
    def tearDown(self):
        if CsvReader.data is not None:
            CsvReader.data = []

    def test_proportion_calculator(self):
        self.statistics = Statistics()
        self.test_data = CsvReader(
            'src/Tests/StatisticsTests/data/proportion.csv').data

        for row in self.test_data:
            self.assertEqual(
                self.statistics.get_proportion(row['SAMPLE SIZE'],
                                               row['OUTCOMES']),
                float(row['RESULT']))
            self.assertEqual(self.statistics.result, float(row['RESULT']))
Beispiel #7
0
 def setUp(self) -> None:
     self.statistics = Statistics()
Beispiel #8
0
 def test_sample_std_deviation_calculator(self):
     self.statistics = Statistics()
     data = [1, 2, 3, 4, 1, 6, 8, 23, 34]
     result = 11.13552873
     self.assertEqual(self.statistics.sample_std_deviation(data), result)
Beispiel #9
0
 def test_instantiate_calculator(self):
     self.statistics = Statistics()
     self.assertIsInstance(self.statistics, Statistics)
 def test_sample_std_deviation_calculator(self):
     self.statistics = Statistics()
     data = [12, 13, 45, 56, 55, 54, 23]
     result = 361
     self.assertEqual(self.statistics.sample_variance(data), result)