@@ -419,7 +419,7 @@ def _deserialize_sklearn( # noqa: PLR0915, C901, PLR0913, PLR0912
419419 strict_version = strict_version ,
420420 )
421421 else :
422- raise ValueError ("Cannot flow_to_sklearn %s" % serialized_type )
422+ raise ValueError (f "Cannot flow_to_sklearn { serialized_type } " )
423423
424424 else :
425425 rval = OrderedDict (
@@ -979,17 +979,15 @@ def flatten_all(list_):
979979 # length 2 is for {VotingClassifier.estimators,
980980 # Pipeline.steps, FeatureUnion.transformer_list}
981981 # length 3 is for ColumnTransformer
982- msg = "Length of tuple of type {} does not match assumptions" .format (
983- sub_component_type ,
984- )
982+ msg = f"Length of tuple of type { sub_component_type } does not match assumptions"
985983 raise ValueError (msg )
986984
987985 if isinstance (sub_component , str ):
988986 if sub_component not in SKLEARN_PIPELINE_STRING_COMPONENTS :
989987 msg = (
990988 "Second item of tuple does not match assumptions. "
991989 "If string, can be only 'drop' or 'passthrough' but"
992- "got %s" % sub_component
990+ f "got { sub_component } "
993991 )
994992 raise ValueError (msg )
995993 elif sub_component is None :
@@ -1002,15 +1000,15 @@ def flatten_all(list_):
10021000 elif not isinstance (sub_component , OpenMLFlow ):
10031001 msg = (
10041002 "Second item of tuple does not match assumptions. "
1005- "Expected OpenMLFlow, got %s" % type (sub_component )
1003+ f "Expected OpenMLFlow, got { type (sub_component )} "
10061004 )
10071005 raise TypeError (msg )
10081006
10091007 if identifier in reserved_keywords :
10101008 parent_model = f"{ model .__module__ } .{ model .__class__ .__name__ } "
1011- msg = "Found element shadowing official " "parameter for {}: {}" . format (
1012- parent_model ,
1013- identifier ,
1009+ msg = (
1010+ "Found element shadowing official "
1011+ f"parameter for { parent_model } : { identifier } "
10141012 )
10151013 raise PyOpenMLError (msg )
10161014
@@ -1035,9 +1033,9 @@ def flatten_all(list_):
10351033 model = None ,
10361034 )
10371035 component_reference : OrderedDict [str , str | dict ] = OrderedDict ()
1038- component_reference [
1039- "oml-python:serialized_object"
1040- ] = COMPOSITION_STEP_CONSTANT
1036+ component_reference ["oml-python:serialized_object" ] = (
1037+ COMPOSITION_STEP_CONSTANT
1038+ )
10411039 cr_value : dict [str , Any ] = OrderedDict ()
10421040 cr_value ["key" ] = identifier
10431041 cr_value ["step_name" ] = identifier
@@ -1218,7 +1216,7 @@ def _check_dependencies(
12181216 for dependency_string in dependencies_list :
12191217 match = DEPENDENCIES_PATTERN .match (dependency_string )
12201218 if not match :
1221- raise ValueError ("Cannot parse dependency %s" % dependency_string )
1219+ raise ValueError (f "Cannot parse dependency { dependency_string } " )
12221220
12231221 dependency_name = match .group ("name" )
12241222 operation = match .group ("operation" )
@@ -1237,7 +1235,7 @@ def _check_dependencies(
12371235 installed_version > required_version or installed_version == required_version
12381236 )
12391237 else :
1240- raise NotImplementedError ("operation '%s ' is not supported" % operation )
1238+ raise NotImplementedError (f "operation '{ operation } ' is not supported" )
12411239 message = (
12421240 "Trying to deserialize a model with dependency "
12431241 f"{ dependency_string } not satisfied."
@@ -1812,10 +1810,7 @@ def _prediction_to_probabilities(
18121810 # then we need to add a column full of zeros into the probabilities
18131811 # for class 3 because the rest of the library expects that the
18141812 # probabilities are ordered the same way as the classes are ordered).
1815- message = "Estimator only predicted for {}/{} classes!" .format (
1816- proba_y .shape [1 ],
1817- len (task .class_labels ),
1818- )
1813+ message = f"Estimator only predicted for { proba_y .shape [1 ]} /{ len (task .class_labels )} classes!"
18191814 warnings .warn (message , stacklevel = 2 )
18201815 openml .config .logger .warning (message )
18211816
@@ -2008,9 +2003,7 @@ def is_subcomponent_specification(values):
20082003 pass
20092004 else :
20102005 raise TypeError (
2011- "Subcomponent flow should be of type flow, but is {}" .format (
2012- type (subcomponent_flow ),
2013- ),
2006+ f"Subcomponent flow should be of type flow, but is { type (subcomponent_flow )} " ,
20142007 )
20152008
20162009 current = {
@@ -2129,8 +2122,7 @@ def instantiate_model_from_hpo_class(
21292122 """
21302123 if not self ._is_hpo_class (model ):
21312124 raise AssertionError (
2132- "Flow model %s is not an instance of sklearn.model_selection._search.BaseSearchCV"
2133- % model ,
2125+ f"Flow model { model } is not an instance of sklearn.model_selection._search.BaseSearchCV" ,
21342126 )
21352127 base_estimator = model .estimator
21362128 base_estimator .set_params (** trace_iteration .get_parameters ())
@@ -2192,8 +2184,7 @@ def _obtain_arff_trace(
21922184 """
21932185 if not self ._is_hpo_class (model ):
21942186 raise AssertionError (
2195- "Flow model %s is not an instance of sklearn.model_selection._search.BaseSearchCV"
2196- % model ,
2187+ f"Flow model { model } is not an instance of sklearn.model_selection._search.BaseSearchCV" ,
21972188 )
21982189 if not hasattr (model , "cv_results_" ):
21992190 raise ValueError ("model should contain `cv_results_`" )
@@ -2228,7 +2219,7 @@ def _obtain_arff_trace(
22282219 # hyperparameter layer_sizes of MLPClassifier
22292220 type = "STRING" # noqa: A001
22302221 else :
2231- raise TypeError ("Unsupported param type in param grid: %s" % key )
2222+ raise TypeError (f "Unsupported param type in param grid: { key } " )
22322223
22332224 # renamed the attribute param to parameter, as this is a required
22342225 # OpenML convention - this also guards against name collisions
0 commit comments