def test_output_table(self): """assert output table is correctly calculated""" vdrive_file = self.filename o_vdrive = VDriveHandler(filename=vdrive_file) o_vdrive.initialize_bank_xaxis() o_vdrive.keep_columns_of_interest() o_vdrive.isolating_banks() o_vdrive.calculate_mean_omega_45() o_vdrive.calculate_sin_omega() o_vdrive.calculate_bank2_iv_ratio_omega_90() o_vdrive.calculate_table2() o_vdrive.calculate_mean_table2() o_vdrive.calculate_output_table() output_table_calculated = o_vdrive.output_table # col 0 top output_table_col0_top_expected = [0.812640079, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, 0.702029178, 0.660330092, 0.733149078, 0.782841806, 0.836570855, 0.857984191, 1.03785908, 1.071183875, 1.000483599] _returned_expected = zip(output_table_calculated[0:21, 0], output_table_col0_top_expected) for _returned, _expected in _returned_expected: if np.isnan(_returned) and np.isnan(_expected): self.assertTrue(True) else: self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff) # col 0 bottom output_table_col0_bottom_expected = [1.01526225, 2.307186346, 0.879244772, 1.163050838, 0.779546467, 1.154482123, 1.578486721, 1.142830628, 1.402556211, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN] _returned_expected = zip(output_table_calculated[-21:, 0], output_table_col0_bottom_expected) for _returned, _expected in _returned_expected: if np.isnan(_returned) and np.isnan(_expected): self.assertTrue(True) else: self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)
def test_mean_table(self): """assert mean table2 is correct""" vdrive_file = self.filename o_vdrive = VDriveHandler(filename=vdrive_file) o_vdrive.initialize_bank_xaxis() o_vdrive.keep_columns_of_interest() o_vdrive.isolating_banks() o_vdrive.calculate_mean_omega_45() o_vdrive.calculate_sin_omega() o_vdrive.calculate_bank2_iv_ratio_omega_90() o_vdrive.calculate_table2() o_vdrive.calculate_mean_table2() mean_calculated = o_vdrive.mean_table mean_expected = [2.133214161, 1.168463923, 0.836050093, 0.969270446, 0.279793507, 0.143081008, 0.413152847, 0.370048531] _calculated_vs_expected = zip(mean_calculated, mean_expected) for _returned, _expected in _calculated_vs_expected: self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)