@@ -408,17 +408,24 @@ def find_germs(target_model, randomize=True, randomization_strength=1e-2,
408
408
409
409
#force the line labels on each circuit to match the state space labels for the target model.
410
410
#this is suboptimal for many-qubit models, so will probably want to revisit this. #TODO
411
- finalGermList = []
412
- if germList is not None :
413
- for ckt in germList :
414
- if ckt ._static :
415
- new_ckt = ckt .copy (editable = True )
416
- new_ckt .line_labels = target_model .state_space .state_space_labels
417
- new_ckt .done_editing ()
418
- finalGermList .append (new_ckt )
419
- else :
420
- ckt .line_labels = target_model .state_space .state_space_labels
421
- finalGermList .append (ckt )
411
+ def fix_line_labels (germListToFix ):
412
+ fixedGermList = []
413
+ if germListToFix is not None :
414
+ for ckt_or_list in germListToFix :
415
+ if isinstance (ckt_or_list , _circuits .Circuit ) and ckt_or_list ._static :
416
+ new_ckt = ckt_or_list .copy (editable = True )
417
+ new_ckt .line_labels = target_model .state_space .state_space_labels
418
+ new_ckt .done_editing ()
419
+ fixedGermList .append (new_ckt )
420
+ elif isinstance (ckt_or_list , _circuits .Circuit ):
421
+ ckt_or_list .line_labels = target_model .state_space .state_space_labels
422
+ fixedGermList .append (ckt_or_list )
423
+ else :
424
+ # This is probably a list of circuits from GRASP w/ return_all = True
425
+ # Call this function recursively
426
+ fixedGermList .append (fix_line_labels (ckt_or_list ))
427
+ return fixedGermList
428
+ finalGermList = fix_line_labels (germList )
422
429
423
430
return finalGermList
424
431
0 commit comments