1import datetime as dt23import polars as pl45from wp39.labels import build_quarter_table, finalize_labels, match_release_dates678def test_release_match_rules(toy_wide, toy_events):9 ev = toy_events.with_columns(pl.when(pl.col("entity_id") == "frd:BBB").then(pl.col("event_date") - pl.duration(days=60))10 .otherwise(pl.col("event_date")).alias("event_date"))11 w = match_release_dates(toy_wide, ev)12 assert (w.filter(pl.col("entity_id") == "frd:AAA")["release_match"] == "ok").all()13 assert (w.filter(pl.col("entity_id") == "frd:BBB")["release_match"] != "ok").all()141516def test_labels_are_not_price_based(toy_wide, toy_events):17 q = finalize_labels(build_quarter_table(match_release_dates(toy_wide, toy_events)))18 assert not any(c.startswith("w") or c.startswith("d_") for c in q.columns)19 assert set(q["y_adverse_opinc"].drop_nulls().unique().to_list()) <= {0, 1}202122def test_release_day_excluded(toy_wide, toy_events):23 from wp39.samples import apply_admissibility, event_cutoffs24 w = match_release_dates(toy_wide, toy_events)25 c = apply_admissibility(event_cutoffs(w, [1]))26 assert (c["cutoff"] < c["A_q"]).all()27