@@ -89,14 +89,10 @@ def flow_to_sklearn(o, **kwargs):
8989 pass
9090
9191 if isinstance (o , dict ):
92- if 'oml:name' in o and 'oml:description' in o :
93- # TODO check if this code is actually called
94- rval = _deserialize_model (o , ** kwargs )
95-
9692 # Check if the dict encodes a 'special' object, which could not
9793 # easily converted into a string, but rather the information to
9894 # re-create the object were stored in a dictionary.
99- elif 'oml-python:serialized_object' in o :
95+ if 'oml-python:serialized_object' in o :
10096 serialized_type = o ['oml-python:serialized_object' ]
10197 value = o ['value' ]
10298 if serialized_type == 'type' :
@@ -128,9 +124,7 @@ def flow_to_sklearn(o, **kwargs):
128124 rval = [flow_to_sklearn (element , ** kwargs ) for element in o ]
129125 if isinstance (o , tuple ):
130126 rval = tuple (rval )
131- elif isinstance (o , (bool , int , float )):
132- rval = o
133- elif isinstance (o , six .string_types ):
127+ elif isinstance (o , (bool , int , float , six .string_types )):
134128 rval = o
135129 elif o is None :
136130 rval = None
@@ -180,12 +174,6 @@ def _serialize_model(model):
180174 identifier , sub_component = sub_component_tuple
181175 sub_component_type = type (sub_component_tuple )
182176
183- # Use only the name of the module (and not all submodules
184- # in the brackets) as the identifier
185- pos = identifier .find ('(' )
186- if pos >= 0 :
187- identifier = identifier [:pos ]
188-
189177 if sub_component is None :
190178 # In a FeatureUnion it is legal to have a None step
191179
@@ -333,13 +321,6 @@ def _deserialize_model(flow, **kwargs):
333321 for name in parameters :
334322 value = parameters .get (name )
335323 rval = flow_to_sklearn (value , components = components )
336-
337- # Replace the component placeholder by the actual flow
338- if isinstance (rval , dict ) and 'oml-python:serialized_object' in rval :
339- parameter_name , step = rval ['value' ].split ('__' )
340- if parameter_name not in component_dict :
341- component_dict [parameter_name ] = OrderedDict ()
342- rval = component_dict [parameter_name ][step ]
343324 parameter_dict [name ] = rval
344325
345326 module_name = model_name .rsplit ('.' , 1 )
@@ -471,7 +452,7 @@ def _serialize_cross_validator(o):
471452
472453 ret ['oml-python:serialized_object' ] = 'cv_object'
473454 name = o .__module__ + "." + o .__class__ .__name__
474- value = OrderedDict (name = name , parameters = parameters )
455+ value = OrderedDict ([[ ' name' , name ], [ ' parameters' , parameters ]] )
475456 ret ['value' ] = value
476457
477458 return ret
0 commit comments