@@ -2030,7 +2030,7 @@ def test_group_time_series_fail_groups_are_none():
20302030def test_group_time_series_ordering_and_group_preserved ():
20312031 # With this test we check that we are only evaluating
20322032 # unseen groups in the future
2033- groups = np .repeat (['a' , 'b' , 'c' , 'd' ], repeats = 3 )
2033+ groups = np .repeat (["a" , "b" , "c" , "d" ], repeats = 3 )
20342034 n_samples = len (groups )
20352035 n_splits = 3
20362036
@@ -2090,28 +2090,22 @@ def test_group_time_series_max_train_size():
20902090
20912091
20922092def test_group_time_series_non_overlap_group ():
2093- letters = list ("abcdefghijk" )
2094- counts = [3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 ]
2095- groups = np .repeat (letters , counts )
2093+ groups = np .repeat (list ("abcdefghijk" ), [3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 ])
20962094 gtss = GroupTimeSeriesSplit (n_splits = 3 )
20972095 splits = gtss .split (groups , groups = groups )
20982096 train , test = next (splits )
20992097 assert_array_equal (train , np .array ([0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ]))
21002098 assert_array_equal (test , np .array ([13 , 14 , 15 , 16 , 17 ]))
21012099 assert_array_equal (
21022100 groups [train ],
2103- np .repeat ([ "a" , "b" , "c" , "d" , "e" ] , [3 , 2 , 3 , 2 , 3 ]),
2101+ np .repeat (list ( "abcde" ) , [3 , 2 , 3 , 2 , 3 ]),
21042102 )
2105- assert_array_equal (groups [test ], np .array ([ "f" , "f" , "g" , "g" , "g" ]))
2103+ assert_array_equal (groups [test ], np .repeat ( list ( "fg" ), [ 2 , 3 ]))
21062104
21072105 train , test = next (splits )
2108- assert_array_equal (
2109- train , np .arange (0 , 18 )
2110- )
2106+ assert_array_equal (train , np .arange (0 , 18 ))
21112107 assert_array_equal (test , np .arange (18 , 23 ))
2112- assert_array_equal (
2113- groups [train ], np .repeat (list ("abcdefg" ), [3 , 2 , 3 , 2 , 3 , 2 , 3 ])
2114- )
2108+ assert_array_equal (groups [train ], np .repeat (list ("abcdefg" ), [3 , 2 , 3 , 2 , 3 , 2 , 3 ]))
21152109 assert_array_equal (groups [test ], np .repeat (list ("hi" ), [2 , 3 ]))
21162110
21172111 train , test = next (splits )
@@ -2121,8 +2115,7 @@ def test_group_time_series_non_overlap_group():
21212115 )
21222116 assert_array_equal (test , np .arange (23 , 28 ))
21232117 assert_array_equal (
2124- groups [train ],
2125- np .repeat (list ("abcdefghi" ), [3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 ])
2118+ groups [train ], np .repeat (list ("abcdefghi" ), [3 , 2 , 3 , 2 , 3 , 2 , 3 , 2 , 3 ])
21262119 )
21272120 assert_array_equal (groups [test ], np .repeat (list ("jk" ), [2 , 3 ]))
21282121
@@ -2134,15 +2127,11 @@ def test_group_time_series_non_overlap_group_with_gap():
21342127 train , test = next (splits )
21352128 assert_array_equal (train , np .arange (0 , 10 ))
21362129 assert_array_equal (test , np .arange (13 , 18 ))
2137- assert_array_equal (
2138- groups [train ], np .repeat (list ("abcd" ), [3 , 2 , 3 , 2 ])
2139- )
2130+ assert_array_equal (groups [train ], np .repeat (list ("abcd" ), [3 , 2 , 3 , 2 ]))
21402131 assert_array_equal (groups [test ], np .repeat (list ("fg" ), [2 , 3 ]))
21412132
21422133 train , test = next (splits )
2143- assert_array_equal (
2144- train , np .arange (0 , 15 )
2145- )
2134+ assert_array_equal (train , np .arange (0 , 15 ))
21462135 assert_array_equal (test , np .arange (18 , 23 ))
21472136 assert_array_equal (
21482137 groups [train ],
@@ -2176,27 +2165,17 @@ def test_group_time_series_non_overlap_group_imbalanced():
21762165 test ,
21772166 np .arange (67 , 117 ),
21782167 )
2179- assert_array_equal (
2180- groups [train ], np .repeat (list ("abcd" ), [20 , 12 , 30 , 2 ])
2181- )
2182- assert_array_equal (
2183- groups [test ], np .repeat (list ("fg" ), [20 , 30 ])
2184- )
2168+ assert_array_equal (groups [train ], np .repeat (list ("abcd" ), [20 , 12 , 30 , 2 ]))
2169+ assert_array_equal (groups [test ], np .repeat (list ("fg" ), [20 , 30 ]))
21852170
21862171 train , test = next (splits )
2187- assert_array_equal (
2188- train , np .arange (0 , 87 )
2189- )
2172+ assert_array_equal (train , np .arange (0 , 87 ))
21902173 assert_array_equal (test , np .arange (117 , 122 ))
2191- assert_array_equal (
2192- groups [train ], np .repeat (list ("abcdef" ), [20 , 12 , 30 , 2 , 3 , 20 ])
2193- )
2174+ assert_array_equal (groups [train ], np .repeat (list ("abcdef" ), [20 , 12 , 30 , 2 , 3 , 20 ]))
21942175 assert_array_equal (groups [test ], np .repeat (list ("hi" ), [2 , 3 ]))
21952176
21962177 train , test = next (splits )
2197- assert_array_equal (
2198- train , np .arange (0 , 119 )
2199- )
2178+ assert_array_equal (train , np .arange (0 , 119 ))
22002179 assert_array_equal (test , np .arange (122 , 127 ))
22012180 assert_array_equal (
22022181 groups [train ], np .repeat (list ("abcdefgh" ), [20 , 12 , 30 , 2 , 3 , 20 , 30 , 2 ])
0 commit comments