Skip to content

Commit

Permalink
Merge pull request #27 from RyanAugust/hotfix
Browse files Browse the repository at this point in the history
Fix datewise merge logic
  • Loading branch information
RyanAugust authored Mar 6, 2024
2 parents 93ccff8 + 8ed4911 commit cb5123d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pysimmmulator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.4.1
3 changes: 1 addition & 2 deletions src/pysimmmulator/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _reformat_for_mmm(self) -> None:
self.mmm_df = pd.DataFrame(
{"date": date_backbone, "id_map": campaign_id_to_date_map}
)
self.mmm_df.set_index("id_map")
self.mmm_df.set_index("id_map", inplace=True)

agg_media_df = self.spend_df.groupby(["channel", "campaign_id"]).sum()[
["daily_impressions", "daily_clicks", "daily_spend", "noisy_cvr"]
Expand All @@ -273,7 +273,6 @@ def _reformat_for_mmm(self) -> None:
agg_media_df.columns = joined_columns

self.mmm_df = self.mmm_df.join(agg_media_df)
del self.mmm_df["id_map"]

logger.info(
"You have completed running step 5a: pivoting the data frame to an MMM format."
Expand Down
8 changes: 8 additions & 0 deletions tests/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ def test_run_with_config_weekly():
cfg["output_params"]["aggregation_level"] = "weekly"
sim = simmm()
sim.run_with_config(config=cfg)


def test_run_with_high_frequency():
cfg = load_parameters.load_config(config_path="example_config.yaml")
cfg["basic_params"]["frequency_of_campaigns"] = 50
sim = simmm()
sim.run_with_config(config=cfg)
assert sim.final_df.dropna().shape[0] > sim.final_df.shape[0] - 5

0 comments on commit cb5123d

Please sign in to comment.