示例#1
0
 def test_confidence_interval_calculator(self):
     test_data = CsvReader("/Tests/Data/randomdata.csv")
     answers = CsvReader('Tests/Data/answers.csv').data
     values = Data(test_data, 'value')
     for column in answers:
         self.assertEqual(self.statistics.conf_interval(values), (float(
             column['conf_int_high']), float(column['conf_int_low'])))
示例#2
0
 def test_proportion(self):
     test_data = CsvReader("/Tests/Data/randomdata.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, 'value')
     for column in answers:
         self.assertEqual(self.statistics.proportion(values),
                          float((column['proportion'])))
示例#3
0
 def test_z_score(self):
     test_data = CsvReader("/Tests/Data/randomdata.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, "value")
     for column in answers:
         self.assertEqual(self.statistics.z_score(values),
                          float((column['zscore'])))
示例#4
0
 def test_sqrt_method_calculator(self):
     test_data = CsvReader("Tests/Data/sq_rt.csv").data
     pprint(test_data)
     for row in test_data:
         self.assertEqual(self.calculator.sq_rt(int(row['Value 1'])),
                          float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
     test_data.clear()
示例#5
0
 def test_pop_std_dev(self):
     test_data = CsvReader("/Tests/Data/randomdata.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, 'value')
     for column in answers:
         self.assertEqual(
             round(self.statistics.pop_standard_dev(values), 4),
             float((column['PSD'])))
示例#6
0
 def test_divide_method_calculator(self):
     test_data = CsvReader("Tests/Data/division.csv").data
     pprint(test_data)
     for row in test_data:
         self.assertEqual(
             self.calculator.divide(row['Value 1'], row['Value 2']),
             float(row['Result']))
         self.assertEqual(self.calculator.result, float(row['Result']))
     test_data.clear()
示例#7
0
 def test_sqrt(self):
     test_data = CsvReader("Tests/testdata/UnitTestSquareRoot.csv").data
     for row in test_data:
         fmt = ".8f"
         result = float(row['Result'])
         if float(result).is_integer():
             fmt = ".1f"
         result = format(float(row['Result']), fmt)
         self.assertEqual(self.calculator.sqrt(row['Value 1']), result)
示例#8
0
 def test_sample_variance(self):
     test_data = CsvReader("/Tests/Data/randomdata.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, 'value')
     x = self.statistics.sample_variance(values)
     self.assertEqual(x, x)
示例#9
0
 def test_CSV(self):
     test_data = CsvReader("Tests/Data/csvtester.csv").data
     for row in test_data:
         self.assertEqual(row["Value 1"], "480")
示例#10
0
 def test_square(self):
     test_data = CsvReader("Tests/testdata/UnitTestSquare.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(self.calculator.square(row['Value 1']), result)
示例#11
0
 def test_divide(self):
     test_data = CsvReader("Tests/testdata/UnitTestDivision.csv").data
     for row in test_data:
         result = format(float(row['Result']), '.9f')
         # print('Result is: ' + result)
         self.assertEqual(self.calculator.divide(row['Value 2'], row['Value 1']), result)
示例#12
0
 def test_multiply(self):
     test_data = CsvReader("Tests/testdata/UnitTestMultiplication.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(self.calculator.multiply(float(row['Value 2']), float(row['Value 1'])), result)
示例#13
0
 def test_subtraction(self):
     test_data = CsvReader("Tests/testdata/UnitTestSubtraction.csv").data
     for row in test_data:
         result = float(row['Result'])
         self.assertEqual(self.calculator.subtract(float(row['Value 2']), float(row['Value 1'])), result)