Exemplo n.º 1
0
 def test_addition(self):
     test_data = CsvReader('Tests/Data/test_addition.csv').data
     for row in test_data:
         self.assertEqual(
             self.calculator.add(int(row['Value 1']), int(row['Value 2'])),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
 def test_multiply(self):
     test_data = CsvReader('Tests/Data/test_multiplication.csv').data
     for row in test_data:
         self.assertEqual(
             self.calculator.multiply(row['Value 1'], row['Value 2']),
             int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
 def test_var_pop_proportion(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(
             self.statistics.variance_pop_proportion(test_data),
             float(row['Var Population Prop']))
 def test_median(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     pprint(test_data)
     for row in test_result:
         self.assertEqual(self.statistics.med(test_data),
                          float(row['Median']))
 def test_division_calculator(self):
     test_Data = CsvReader("/Tests/Data/UnitTestDivision.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"]))
def pop_correlation_coefficient(data):
    x_data = CsvReader('Tests/Data/female_height.csv').data
    y_data = CsvReader('Tests/Data/male_height.csv').data
    x = pop_stand_dev(x_data)
    y = pop_stand_dev(y_data)
    divisor = multiplication(x, y)
    z = len(data)

    # Covariance calculation:
    a = subtraction(data, sampleMean)
    b = subtraction(data, population_mean)
    c = multiplication(a, b)
    covariance = division(z, (sum(c)))

    # Population Correlation Coefficient calculation:
    d = division(divisor, covariance)
    return d
Exemplo n.º 7
0
 def test_square_root(self):
     test_data = CsvReader('Tests/Data/test_square_root.csv').data
     for row in test_data:
         self.assertAlmostEqual(self.calculator.sqrt(int(row['Value 1'])),
                                float(row['Result']),
                                places=4)
         self.assertAlmostEqual(self.calculator.result,
                                float(row['Result']),
                                places=4)
 def test_p_value(self):
     test_data = CsvNormalReader('Tests/Data/normal_dist.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     z_score_test_result = str(
         self.statistics.z_score(
             CsvReaderStats('Tests/Data/female_height.csv').data))
     actual = test_result[0]['P Value']
     for test_value in test_data:
         expected = test_value.split(",")
         if z_score_test_result == expected[0]:
             self.assertAlmostEqual(actual, expected[1])
 def test_pop_correlation_coefficient(self):
     test_data_f = CsvReaderStats('Tests/Data/female_height.csv').data
     test_data_m = CsvReaderStats('Tests/Data/male_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(
             self.statistics.pop_correlation_coefficient(
                 test_data_f, test_data_m),
             float(row['Population '
                       'Correlation '
                       'Coefficient']))
Exemplo n.º 10
0
    def __init__(self, filepath):

        super().__init__()
        self.data = CsvReader(filepath)
 def test_sample_var_prop(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.var_sam_prop(test_data),
                          float(row['Variance of Sample Proportion']))
 def test_sample_st_dev(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.sample_st_dev(test_data),
                          float(row['Sample SD']))
 def test_proportion(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.proportion(test_data),
                          float(row['Proportion']))
 def test_population_stand_deviation(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.population_st_dev(test_data),
                          float(row['Population SD (Female)']))
 def test_z_score(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.z_score(test_data),
                          float(row['ZScore']))
 def test_population_variance(self):
     test_data = CsvReaderStats('Tests/Data/female_height.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_result:
         self.assertEqual(self.statistics.population_variance(test_data),
                          float(row['Population Variance']))
 def test_mode(self):
     test_data = CsvReader('Tests/Data/female_data.csv').data
     test_result = CsvReader('Tests/Data/Results_Statistics_Calc.csv').data
     for row in test_data:
         self.assertEqual(self.statistics.mod(), float(row['Mode']))
         self.assertEqual(self.statistics.result, test_result(row['Mode']))
Exemplo n.º 18
0
 def test_add(self):
     test_data = CsvReader("Tests/Data/CSV_reader.csv").data
     for row in test_data:
         self.assertEqual(row['Value 1'], '580')
Exemplo n.º 19
0
 def test_square(self):
     test_data = CsvReader('Tests/Data/test_square.csv').data
     for row in test_data:
         self.assertEqual(self.calculator.squaring(int(row['Value 1'])),
                          int(row['Result']))
         self.assertEqual(self.calculator.result, int(row['Result']))
 def test_vsp(self):
     test_data = CsvReader("Tests/Data/datapoints.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, 'value')
     x = self.statistics.vsp(values)
     self.assertEqual(x, x)
 def test_zscore(self):
     test_data = CsvReader("Tests/Data/datapoints.csv")
     answers = CsvReader("Tests/Data/answers.csv").data
     values = Data(test_data, "value")
 def setUp(self) -> None:
     self.csv_reader = CsvReader('Tests/Data/female_height.csv')
Exemplo n.º 23
0
 def test_CSV(self):
     test_data = CsvReader("Tests/Data/CSV_reader.csv").data
     for row in test_data:
         self.assertEqual(row["Value 1"], "580")