File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -422,12 +422,9 @@ def _validate_pauli_dist(pauli_dist: dict) -> bool:
422422
423423def _pauli_dist_from_commuting_groups (commuting_groups : tuple [dict ]):
424424 """Construct the total Pauli word distribution from the commuting groups."""
425- total_pauli_dist = defaultdict (int )
426-
425+ total_pauli_dist = Counter ()
427426 for group in commuting_groups :
428- for pauli_word , frequency in group .items ():
429- total_pauli_dist [pauli_word ] += frequency
430-
427+ total_pauli_dist .update (group )
431428 return total_pauli_dist
432429
433430
Original file line number Diff line number Diff line change @@ -2097,8 +2097,7 @@ def cost_pauli_group(pauli_dist: dict):
20972097 a commuting group of Pauli words.
20982098
20992099 """
2100- gate_count_lst = []
2101- for pauli_word , count in pauli_dist .items ():
2102- gate_count_lst .append (GateCount (PauliRot .resource_rep (pauli_word ), count ))
2103-
2104- return gate_count_lst
2100+ return [
2101+ GateCount (PauliRot .resource_rep (pauli_word ), count )
2102+ for pauli_word , count in pauli_dist .items ()
2103+ ]
You can’t perform that action at this time.
0 commit comments