def test_setup_state_varsets(self): this_cl = Crosslevel() this_cl._setup_state(self.df_h, self.df_l, self.df_links, self.timevar, self.groupvar_h, self.groupvar_l) self.assertEqual(this_cl.groupvar_h, self.groupvar_h) self.assertEqual(this_cl.groupvar_l, self.groupvar_l) self.assertEqual(this_cl.timevar, self.timevar)
def test_setup_state_df(self): this_cl = Crosslevel() this_cl._setup_state(self.df_h, self.df_l, self.df_links, self.timevar, self.groupvar_h, self.groupvar_l) self.assertIsInstance(this_cl.df, pd.DataFrame) df_merged = Crosslevel.merge_levels(self.df_h, self.df_l, self.df_links) pd.testing.assert_frame_equal(this_cl.df, df_merged) with self.assertRaises(AssertionError) as _: pd.testing.assert_frame_equal(this_cl.df, self.df_h)
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)