Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very small clean up in the count_ops() method #4002

Closed
wants to merge 9 commits into from
6 changes: 2 additions & 4 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,8 @@ def count_ops(self):
"""
count_ops = {}
for instr, _, _ in self._data:
if instr.name in count_ops.keys():
count_ops[instr.name] += 1
else:
count_ops[instr.name] = 1
count_ops[instr.name] = count_ops.get(instr.name, 0) + 1

return OrderedDict(sorted(count_ops.items(), key=lambda kv: kv[1], reverse=True))

def num_connected_components(self, unitary_only=False):
Expand Down