Skip to content

feature: add Circuit instruction counting#1297

Open
baihaoyu11 wants to merge 2 commits into
amazon-braket:mainfrom
baihaoyu11:unitaryhack-circuit-count
Open

feature: add Circuit instruction counting#1297
baihaoyu11 wants to merge 2 commits into
amazon-braket:mainfrom
baihaoyu11:unitaryhack-circuit-count

Conversation

@baihaoyu11

Copy link
Copy Markdown

Issue #, if available: Fixes #1235

Description of changes:
Adds Circuit.count(instruction_name: str | None = None) so callers can count all instructions in a circuit or count instructions matching an operator name case-insensitively.

Testing done:

  • .venv/bin/python -m pytest test/unit_tests/braket/circuits/test_circuit.py -k 'count' (10 passed)
  • .venv/bin/python -m pytest test/unit_tests/braket/circuits/test_circuit.py (338 passed, 2 xfailed)
  • .venv/bin/python -m ruff format --check src/braket/circuits/circuit.py test/unit_tests/braket/circuits/test_circuit.py
  • .venv/bin/python -m ruff check src/braket/circuits/circuit.py

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add a method to count instructions in the circuit.
Add tests for counting instructions in Circuit class
@baihaoyu11 baihaoyu11 requested a review from a team as a code owner June 10, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Easily count instructions in a circuit

1 participant