def test_table2_bank1(self):
        """assert table2 works for banks 1"""
        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()

        # bank1
        bank1_table2_calculated = o_vdrive.bank1.table2
        # col 0 - first 17 elements
        bank1_table2_expected_col_0 = [1.733535324, np.NaN, np.NaN, np.NaN, np.NaN,
                                       np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN,
                                       np.NaN, 1.497578584, 1.408625503, 1.563963996,
                                       1.669969226, 1.784584795]
        _returned_expected = zip(bank1_table2_calculated[:17, 0], bank1_table2_expected_col_0)
        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 - last 17 elements
        bank1_table2_expected_col_0 = [2.430585, 2.776015, 2.66494, 2.263505, 2.796755,
                                       2.478, 2.0942, 2.009715, 2.978445, 2.883115,
                                       1.982715, 2.527035]
        _returned_expected = zip(bank1_table2_calculated[-12:, 0], bank1_table2_expected_col_0)
        for _returned, _expected in _returned_expected:
            self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)

        # col 2
        bank1_table2_expected_col_2 = [0.594866602, np.NaN, np.NaN, np.NaN, np.NaN,
                                       np.NaN, np.NaN, np.NaN, np.NaN, np.NaN, np.NaN,
                                       np.NaN, 0.505373308, 0.538642618, 0.649678462,
                                       0.588877515, 0.568471623]
        _returned_expected = zip(bank1_table2_calculated[:17, 2], bank1_table2_expected_col_2)
        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 3 - last 17 elements
        bank1_table2_expected_col_3 = [0.897326, 0.9429855, 0.8060015, 1.102025,
                                       0.802711, 0.9386, 0.8509655, 1.007736,
                                       0.853531, 0.8713325, 0.79393, 0.8506025]
        _returned_expected = zip(bank1_table2_calculated[-12:, 3], bank1_table2_expected_col_3)
        for _returned, _expected in _returned_expected:
            self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)
    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)
    def test_table2_bank2(self):
        """assert sin(omega)*iv works for banks 2"""
        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()

        bank2_table_calculated = o_vdrive.bank2.table2

        # top part of col 0
        top_part_col_0_calculated = bank2_table_calculated[0:10, 0]
        top_part_col_0_expected = [1.655954058, 1.589657279, 1.379463645, 1.03711278,
                                   1.64395099, 0.898081364, 1.146506992, 0.907738153,
                                   0.879945042, 0.885502018]
        _returned_vs_expected = zip(top_part_col_0_calculated, top_part_col_0_expected)
        for _returned, _expected in _returned_vs_expected:
            self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)

        # top part of col 2
        top_part_col_2_calculated = bank2_table_calculated[0:10, 2]
        top_part_col_2_expected = [1.075608189, 0.810566687, 0.741113623, 0.652813589,
                                   0.553629733, 1.147922011, 0.766310021, 0.537520495,
                                   0.48164904, 0.627781758]
        _returned_vs_expected = zip(top_part_col_2_calculated, top_part_col_2_expected)
        for _returned, _expected in _returned_vs_expected:
            self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)

        # bottom part of col 0
        bottom_part_col_0_calculated = bank2_table_calculated[-12:, 0]
        bottom_part_col_0_expected = [2.478929294, 2.189971774, 3.270427705, 2.801114774,
                                      1.88676372, 2.323232895, 1.96169545, 2.769796199,
                                      2.55591012, 2.735695043, 3.342786421, 3.290499535]
        _returned_vs_expected = zip(bottom_part_col_0_calculated, bottom_part_col_0_expected)
        for _returned, _expected in _returned_vs_expected:
            self.assertAlmostEqual(_returned, _expected, delta=self.maxDiff)