Ejemplo n.º 1
0
    def test_compute_product(self):
        """ Test compute_product() """
        df = Crosslevel.merge_levels(self.df_h, self.df_l, self.df_links)
        first_col = df.columns[0]
        second_col = df.columns[1]
        product_1 = Crosslevel.compute_product(df, first_col, second_col)

        product_2 = df[first_col] * df[second_col]

        pd.testing.assert_series_equal(product_1, product_2)
Ejemplo n.º 2
0
    def test_worker_product(self):
        """ Test simple product worker chain """

        # Compute colaresian product by calling static worker directly
        df_merged = Crosslevel.merge_levels(self.df_h, self.df_l,
                                            self.df_links)
        job = self.job_product
        result_1 = Crosslevel.compute_product(df=df_merged,
                                              col_a=job['col_h'],
                                              col_b=job['col_l'])

        # Compute by calling the worker chain

        this_cl = Crosslevel()
        this_cl._setup_state(self.df_h, self.df_l, self.df_links, self.timevar,
                             self.groupvar_h, self.groupvar_l)

        result_2 = this_cl.worker(self.local_settings, job)

        pd.testing.assert_series_equal(result_1, result_2)