@@ -1236,25 +1236,46 @@ def check_equality(
12361236 if len (runs ) == 0 :
12371237 return result
12381238
1239- # Check meta
1240- if meta :
1241- ignore = ["objectives" , "budgets" , "wallclock_limit" ]
1242-
1243- m1 = runs [0 ].get_meta ()
1239+ # Check if objectives are mergeable
1240+ if objectives :
1241+ o1 = None
12441242 for run in runs :
1245- m2 = run .get_meta ()
1243+ o2 = run .get_objectives ()
12461244
1247- for k , v in m1 .items ():
1248- # Don't check on objectives or budgets
1249- if k in ignore :
1250- continue
1245+ if o1 is None :
1246+ o1 = o2
1247+ continue
12511248
1252- if k not in m2 or m2 [k ] != v :
1249+ if len (o1 ) != len (o2 ):
1250+ raise NotMergeableError (
1251+ "Objectives of runs are not equal." , RunInequality .INEQ_OBJECTIVE
1252+ )
1253+
1254+ for o1_ , o2_ in zip (o1 , o2 ):
1255+ try :
1256+ o1_ .merge (o2_ )
1257+ except NotMergeableError :
12531258 raise NotMergeableError (
1254- "Meta data of runs are not equal." , RunInequality .INEQ_META
1259+ "Objectives of runs are not equal." , RunInequality .INEQ_OBJECTIVE
12551260 )
12561261
1257- result ["meta" ] = m1
1262+ assert o1 is not None
1263+ serialized_objectives = [o .to_json () for o in o1 ]
1264+ result ["objectives" ] = serialized_objectives
1265+ if meta :
1266+ result ["meta" ]["objectives" ] = serialized_objectives
1267+
1268+ # Also check if budgets are the same
1269+ if budgets :
1270+ b1 = runs [0 ].get_budgets (include_combined = False )
1271+ for run in runs :
1272+ b2 = run .get_budgets (include_combined = False )
1273+ if b1 != b2 :
1274+ raise NotMergeableError ("Budgets of runs are not equal." , RunInequality .INEQ_BUDGET )
1275+
1276+ result ["budgets" ] = b1
1277+ if meta :
1278+ result ["meta" ]["budgets" ] = b1
12581279
12591280 # Make sure the same configspace is used
12601281 # Otherwise it does not make sense to merge
@@ -1270,40 +1291,24 @@ def check_equality(
12701291
12711292 result ["configspace" ] = cs1
12721293
1273- # Also check if budgets are the same
1274- if budgets :
1275- b1 = runs [0 ].get_budgets (include_combined = False )
1276- for run in runs :
1277- b2 = run .get_budgets (include_combined = False )
1278- if b1 != b2 :
1279- raise NotMergeableError ("Budgets of runs are not equal." , RunInequality .INEQ_BUDGET )
1280-
1281- result ["budgets" ] = b1
1282- if meta :
1283- result ["meta" ]["budgets" ] = b1
1294+ # Check meta
1295+ if meta :
1296+ ignore = ["objectives" , "budgets" , "wallclock_limit" ]
12841297
1285- # And if objectives are the same
1286- if objectives :
1287- o1 = None
1298+ m1 = runs [0 ].get_meta ()
12881299 for run in runs :
1289- o2 = run .get_objectives ()
1290-
1291- if o1 is None :
1292- o1 = o2
1293- continue
1300+ m2 = run .get_meta ()
12941301
1295- if len ( o1 ) != len ( o2 ):
1296- raise NotMergeableError (
1297- "Objectives of runs are not equal." , RunInequality . INEQ_OBJECTIVE
1298- )
1302+ for k , v in m1 . items ( ):
1303+ # Don't check on objectives or budgets
1304+ if k in ignore :
1305+ continue
12991306
1300- for o1_ , o2_ in zip (o1 , o2 ):
1301- o1_ .merge (o2_ )
1307+ if k not in m2 or m2 [k ] != v :
1308+ raise NotMergeableError (
1309+ "Meta data of runs are not equal." , RunInequality .INEQ_META
1310+ )
13021311
1303- assert o1 is not None
1304- serialized_objectives = [o .to_json () for o in o1 ]
1305- result ["objectives" ] = serialized_objectives
1306- if meta :
1307- result ["meta" ]["objectives" ] = serialized_objectives
1312+ result ["meta" ] = m1
13081313
13091314 return result
0 commit comments