File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,27 @@ def test_its(validation_time):
349
349
result .summary ()
350
350
351
351
352
+ def test_its_with_invalid_validation_time ():
353
+ """
354
+ Test that we get a ValueError when validation_time is greater than validation_time.
355
+ """
356
+ df = (
357
+ cp .load_data ("its" )
358
+ .assign (date = lambda x : pd .to_datetime (x ["date" ]))
359
+ .set_index ("date" )
360
+ )
361
+ treatment_time = pd .to_datetime ("2017-01-01" )
362
+ validation_time = pd .to_datetime ("2018-01-01" )
363
+ with pytest .raises (ValueError ):
364
+ _ = cp .pymc_experiments .InterruptedTimeSeries (
365
+ df ,
366
+ treatment_time ,
367
+ validation_time = validation_time ,
368
+ formula = "y ~ 1 + t + C(month)" ,
369
+ model = cp .pymc_models .LinearRegression (sample_kwargs = sample_kwargs ),
370
+ )
371
+
372
+
352
373
@pytest .mark .integration
353
374
def test_its_covid ():
354
375
"""
@@ -409,6 +430,23 @@ def test_sc(validation_time):
409
430
result .summary ()
410
431
411
432
433
+ def test_sc_with_invalid_validation_time ():
434
+ """
435
+ Test that we get a ValueError when validation_time is greater than validation_time.
436
+ """
437
+ df = cp .load_data ("sc" )
438
+ treatment_time = 70
439
+ validation_time = 80
440
+ with pytest .raises (ValueError ):
441
+ _ = cp .pymc_experiments .SyntheticControl (
442
+ df ,
443
+ treatment_time ,
444
+ validation_time = validation_time ,
445
+ formula = "actual ~ 0 + a + b + c + d + e + f + g" ,
446
+ model = cp .pymc_models .WeightedSumFitter (sample_kwargs = sample_kwargs ),
447
+ )
448
+
449
+
412
450
@pytest .mark .integration
413
451
def test_sc_brexit ():
414
452
"""
You can’t perform that action at this time.
0 commit comments