test: reject unsorted rebalance dates

This commit is contained in:
ao gong
2026-08-21 21:25:11 +08:00
parent 0a236622f3
commit b4f7b74c04
+10
View File
@@ -141,6 +141,16 @@ def test_weight_table_rejects_duplicate_rebalance_dates() -> None:
scores_to_weight_table(scores, top_k=1) scores_to_weight_table(scores, top_k=1)
def test_weight_table_rejects_unsorted_rebalance_dates() -> None:
scores = pd.DataFrame(
{"A": [1.0, 2.0]},
index=pd.to_datetime(["2026-01-07", "2026-01-05"]),
)
with pytest.raises(ValueError, match="chronological order"):
scores_to_weight_table(scores, top_k=1)
def test_weight_table_rejects_non_numeric_scores() -> None: def test_weight_table_rejects_non_numeric_scores() -> None:
scores = pd.DataFrame({"A": ["high"], "B": ["low"]}) scores = pd.DataFrame({"A": ["high"], "B": ["low"]})