@@ -1232,6 +1232,13 @@ def structure_instances_list(x, type):
1232
1232
if "score" in inst_data .keys ():
1233
1233
inst = converter .structure (inst_data , PredictedInstance )
1234
1234
else :
1235
+ if (
1236
+ "from_predicted" in inst_data
1237
+ and inst_data ["from_predicted" ] is not None
1238
+ ):
1239
+ inst_data ["from_predicted" ] = converter .structure (
1240
+ inst_data ["from_predicted" ], PredictedInstance
1241
+ )
1235
1242
inst = converter .structure (inst_data , Instance )
1236
1243
inst_list .append (inst )
1237
1244
@@ -1243,14 +1250,13 @@ def structure_instances_list(x, type):
1243
1250
1244
1251
# Structure forward reference for PredictedInstance for the Instance.from_predicted
1245
1252
# attribute.
1246
- converter .register_structure_hook (
1247
- ForwardRef ( "PredictedInstance" ) ,
1248
- lambda x , _ : converter .structure (x , PredictedInstance ),
1253
+ converter .register_structure_hook_func (
1254
+ lambda t : t . __class__ is ForwardRef ,
1255
+ lambda v , t : converter .structure (v , t . __forward_value__ ),
1249
1256
)
1250
-
1251
1257
# converter.register_structure_hook(
1252
- # PredictedInstance,
1253
- # lambda x, type : converter.structure(x, PredictedInstance),
1258
+ # ForwardRef(" PredictedInstance") ,
1259
+ # lambda x, _ : converter.structure(x, PredictedInstance),
1254
1260
# )
1255
1261
1256
1262
# We can register structure hooks for point arrays that do nothing
0 commit comments