2222 "_check_specification_and_determine_p_n" ,
2323 "multiclass_fold_partitioning_generator_22" ,
2424 "multiclass_fold_partitioning_generator_2n" ,
25- "multiclass_fold_partitioning_generator_kn"
25+ "multiclass_fold_partitioning_generator_kn" ,
2626]
2727
2828
@@ -75,9 +75,7 @@ def integer_partitioning_generator(n: int, m: int): # pylint: disable=invalid-n
7575 x [m ] = n - s [m - 1 ]
7676
7777
78- def all_integer_partitioning_generator (
79- n , k , non_zero , max_count
80- ): # pylint: disable=invalid-name
78+ def all_integer_partitioning_generator (n , k , non_zero , max_count ): # pylint: disable=invalid-name
8179 """
8280 Generate all integer partitioning of n to k parts (including 0 parts)
8381
@@ -114,8 +112,7 @@ def not_enough_diverse_folds(p_values, n_values):
114112 """
115113
116114 return len (p_values ) > 1 and (
117- sum (p_tmp > 0 for p_tmp in p_values ) < 2
118- or sum (n_tmp > 0 for n_tmp in n_values ) < 2
115+ sum (p_tmp > 0 for p_tmp in p_values ) < 2 or sum (n_tmp > 0 for n_tmp in n_values ) < 2
119116 )
120117
121118
@@ -185,17 +182,13 @@ def fold_partitioning_generator(
185182 for p_a in range (min_p_a , max_p_a + 1 ):
186183 p_b = p - p_a
187184
188- for ps_a in all_integer_partitioning_generator (
189- p_a , k_a , p_non_zero , c_a - n_non_zero
190- ):
185+ for ps_a in all_integer_partitioning_generator (p_a , k_a , p_non_zero , c_a - n_non_zero ):
191186 if any (p_tmp < p_min for p_tmp in ps_a ):
192187 continue
193188
194189 ns_a = [c_a - tmp for tmp in ps_a ]
195190
196- for ps_b in all_integer_partitioning_generator (
197- p_b , k_b , p_non_zero , c_b - n_non_zero
198- ):
191+ for ps_b in all_integer_partitioning_generator (p_b , k_b , p_non_zero , c_b - n_non_zero ):
199192 if any (p_tmp < p_min for p_tmp in ps_b ):
200193 continue
201194
@@ -210,7 +203,7 @@ def fold_partitioning_generator(
210203 yield ps_all , ns_all
211204
212205
213- def _check_specification_and_determine_p_n (dataset : dict , folding : dict ) -> ( int , int ) :
206+ def _check_specification_and_determine_p_n (dataset : dict , folding : dict ) -> tuple [ int , int ] :
214207 """
215208 Checking if the dataset specification is correct and determining the p and n values
216209
@@ -271,14 +264,10 @@ def kfolds_generator(evaluation: dict, available_scores: list, repeat_idx=0):
271264
272265 if "sens" not in available_scores and "bacc" not in available_scores :
273266 p_zero = True
274- logger .info (
275- "sens and bacc not among the reported scores, p=0 folds are also considered"
276- )
267+ logger .info ("sens and bacc not among the reported scores, p=0 folds are also considered" )
277268 if "spec" not in available_scores and "bacc" not in available_scores :
278269 n_zero = True
279- logger .info (
280- "spec and bacc not among the reported scores, n=0 folds are also considered"
281- )
270+ logger .info ("spec and bacc not among the reported scores, n=0 folds are also considered" )
282271
283272 if evaluation ["dataset" ].get ("dataset_name" ) is not None :
284273 evaluation ["dataset" ][
@@ -321,17 +310,13 @@ def repeated_kfolds_generator(evaluation: dict, available_scores: list):
321310 dict: one evaluation
322311 """
323312 n_repeats = evaluation ["folding" ].get ("n_repeats" , 1 )
324- generators = [
325- kfolds_generator (evaluation , available_scores , idx ) for idx in range (n_repeats )
326- ]
313+ generators = [kfolds_generator (evaluation , available_scores , idx ) for idx in range (n_repeats )]
327314
328315 if n_repeats > 1 :
329316 for folds in itertools .product (* generators ):
330317 yield {
331318 "dataset" : copy .deepcopy (evaluation ["dataset" ]),
332- "folding" : {
333- "folds" : [fold for fold_list in folds for fold in fold_list ]
334- },
319+ "folding" : {"folds" : [fold for fold_list in folds for fold in fold_list ]},
335320 "fold_score_bounds" : copy .deepcopy (evaluation .get ("fold_score_bounds" )),
336321 "aggregation" : evaluation .get ("aggregation" ),
337322 }
@@ -370,6 +355,7 @@ def experiment_kfolds_generator(experiment: dict, available_scores: list):
370355 "aggregation" : experiment ["aggregation" ],
371356 }
372357
358+
373359def multiclass_fold_partitioning_generator_22 (n0 : int , n1 : int , c0 : int ):
374360 """
375361 Generates the configurations for two folds of cardinalities n0 and n1 and two
@@ -387,10 +373,8 @@ def multiclass_fold_partitioning_generator_22(n0: int, n1: int, c0: int):
387373 lower_bound = max (c0 - n1 , 0 )
388374
389375 for c_00 in range (lower_bound , upper_bound + 1 ):
390- yield {
391- 0 : (c_00 , n0 - c_00 ),
392- 1 : (c0 - c_00 , n1 - c0 + c_00 )
393- }
376+ yield {0 : (c_00 , n0 - c_00 ), 1 : (c0 - c_00 , n1 - c0 + c_00 )}
377+
394378
395379def multiclass_fold_partitioning_generator_2n (n0 : int , n1 : int , cs : list ):
396380 """
@@ -410,14 +394,10 @@ def multiclass_fold_partitioning_generator_2n(n0: int, n1: int, cs: list):
410394 yield part
411395 else :
412396 for part_deep in multiclass_fold_partitioning_generator_2n (
413- part [0 ][1 ],
414- part [1 ][1 ],
415- cs [1 :]
416- ):
417- yield {
418- 0 : (part [0 ][0 ], * (part_deep [0 ])),
419- 1 : (part [1 ][0 ], * (part_deep [1 ]))
420- }
397+ part [0 ][1 ], part [1 ][1 ], cs [1 :]
398+ ):
399+ yield {0 : (part [0 ][0 ], * (part_deep [0 ])), 1 : (part [1 ][0 ], * (part_deep [1 ]))}
400+
421401
422402def multiclass_fold_partitioning_generator_kn (ns : list , cs : list ):
423403 """
0 commit comments