def test_stdev(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float(column['Stdev']) listx = [] for row in test_data: result = float(row['Array']) listx.append(result) self.statisticss.stdev_(listx) self.assertEqual(round(self.statisticss.result), round(result_test))
def test_sqrt(self): test_data = csvreader('Tests/csvdata/UnitTestSquareRoot.csv').data for row in test_data: result = float(row['Result']) self.assertAlmostEqual(self.calculator.sqrt_(row['Value 1']), result) self.assertAlmostEqual(self.calculator.result, result)
def test_populationvar(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float(column['populationvar']) listx = [] for row in test_data: result = float(row['Array']) listx.append(result) self.assertEqual(round(self.extendedstat.populationvar(listx)), round(result_test))
def test_pvalue(self): test_data = csvreader('Tests/csvdata/UnitArgument.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float(column['pvalue']) for column in test_data: a = float(column['a']) b = float(column['b']) c = float(column['c']) d = float(column['d']) self.assertAlmostEqual(self.extendedstat.pvalue_(a, b, c, d), result_test)
def test_div(self): test_data = csvreader('Tests/csvdata/UnitTestDivision.csv').data for row in test_data: result = float(row['Result']) self.assertAlmostEqual( self.calculator.division(row['Value 1'], row['Value 2']), result) self.assertAlmostEqual(self.calculator.result, result)
def test_times(self): test_data = csvreader('Tests/csvdata/UnitTestMultiplication.csv').data for row in test_data: result = float(row['Result']) self.assertEqual( self.calculator.multiply(row['Value 1'], row['Value 2']), result) self.assertEqual(self.calculator.result, result)
def test_subtraction(self): test_data = csvreader('Tests/csvdata/UnitTestSubtraction.csv').data for row in test_data: result = float(row['Result']) self.assertEqual( self.calculator.subtraction(row['Value 1'], row['Value 2']), result) self.assertEqual(self.calculator.result, result)
def test_zscore(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float(column['zscore']) z = float(column['zvalue4zscore']) listx = [] for row in test_data: result = float(row['Array']) listx.append(result) self.assertEqual(round(self.extendedstat.zscore_(z, listx)), round(result_test))
def test_Variance_of_population_proportion(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float( column['Variance_of_population_proportion']) listx = [] for row in test_data: result = float(row['Array']) listx.append(result) self.assertAlmostEqual( self.extendedstat.Variance_of_population_proportion_(listx), result_test)
def test_sample(self): test_data = csvreader('Tests/csvdata/Array3.csv').data #test_result = csvreader('Tests/csvdata/Array3_result2.csv').data listx = [] #since this not a sudo random number genrator we can predict the lenght! for row in test_data: result = float(row['Array']) listx.append(result) self.extendedstat.sample_(listx, 50) self.assertEqual(len(listx), 309)
def test_population_correlation_coefficient(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test = float( column['population_correlation_coefficient']) listx = [] listy = [] for row in test_data: result = float(row['Array']) listx.append(result) result2 = float(row['Array2']) listy.append(result2) self.assertAlmostEqual( float( self.extendedstat.population_correlation_coefficient_( listx, listy)), float(result_test))
def test_cinterval(self): test_data = csvreader('Tests/csvdata/Array3.csv').data test_result = csvreader('Tests/csvdata/Array3_result2.csv').data for column in test_result: result_test1 = float(column['cintreval1']) result_test2 = float(column['cintreval2']) listx = x = [] for row in test_data: result = float(row['Array']) listx.append(result) x = self.extendedstat.cintreval_(listx) try: self.assertAlmostEqual(x[0], result_test1) self.assertAlmostEqual(x[1], result_test2) except AssertionError as e: print("Cintreval has AsserstionError:", e) assert 0
def setUp(self) -> None: self.csv_reader = csvreader('Tests/csvdata/UnitTestStudentInfo.csv')