@@ -256,7 +256,7 @@ def test_nxx(self):
256256 testing .assert_frame_equal (output , expected )
257257
258258
259- class PrePostChangeTests (absltest .TestCase ):
259+ class PrePostChangeTests (parameterized .TestCase ):
260260 n = 40
261261 df = pd .DataFrame ({
262262 'x' : np .random .choice (range (20 ), n ),
@@ -428,7 +428,7 @@ def test_complex(self):
428428 testing .assert_frame_equal (output , expected )
429429
430430
431- class CUPEDTests (absltest .TestCase ):
431+ class CUPEDTests (parameterized .TestCase ):
432432 n = 40
433433 df = pd .DataFrame ({
434434 'x' : np .random .choice (range (20 ), n ),
@@ -2362,6 +2362,33 @@ def test_different_metrics_have_different_fingerprints(self):
23622362 )
23632363 self .assertLen (fingerprints , len (distinct_ops ))
23642364
2365+ @parameterized .parameters ([operations .CUPED , operations .PrePostChange ])
2366+ def test_cuped_prepost_with_duplicate_names_one_covariate (self , op ):
2367+ s = metrics .Sum ('x' )
2368+ cov = metrics .Sum ('x' , where = 'x>0.1' , name = 'foo' )
2369+ cov_dup = metrics .Sum ('x' , where = 'x>0.1' )
2370+ jk = operations .Jackknife ('cookie' , confidence = 0.9 )
2371+ op_dup = op ('grp' , 1 , s , cov_dup , 'grp4' )
2372+ op = op ('grp' , 1 , s , cov , 'grp4' )
2373+ output = jk (op_dup ).compute_on (self .df ).display (return_formatted_df = True )
2374+ expected = jk (op ).compute_on (self .df ).display (return_formatted_df = True )
2375+ testing .assert_frame_equal (output , expected )
2376+
2377+ @parameterized .parameters ([operations .CUPED , operations .PrePostChange ])
2378+ def test_cuped_prepost_with_duplicate_names_multiple_covariates (self , op ):
2379+ s = metrics .Sum ('x' , name = 'foo' )
2380+ cov_dup = [
2381+ metrics .Sum ('x' , where = 'x>0.1' , name = 'foo' ),
2382+ metrics .Sum ('y' , name = 'foo' ),
2383+ ]
2384+ cov = [metrics .Sum ('x' , where = 'x>0.1' ), metrics .Sum ('y' )]
2385+ jk = operations .Jackknife ('cookie' , confidence = 0.9 )
2386+ op_dup = op ('grp' , 1 , s , cov_dup , 'grp4' )
2387+ op = op ('grp' , 1 , s , cov , 'grp4' )
2388+ output = jk (op_dup ).compute_on (self .df ).display (return_formatted_df = True )
2389+ expected = jk (op ).compute_on (self .df ).display (return_formatted_df = True )
2390+ testing .assert_frame_equal (output , expected )
2391+
23652392
23662393if __name__ == '__main__' :
23672394 absltest .main ()
0 commit comments