Skip to content

feat: add Circuit instruction counting#1298

Open
yanziwei wants to merge 1 commit into
amazon-braket:mainfrom
yanziwei:circuit-instruction-count
Open

feat: add Circuit instruction counting#1298
yanziwei wants to merge 1 commit into
amazon-braket:mainfrom
yanziwei:circuit-instruction-count

Conversation

@yanziwei

Copy link
Copy Markdown

Summary

  • add Circuit.count() to count instructions by lowercase operator name
  • support Circuit.count("cnot") for a single instruction type and Circuit.count() for all instruction counts
  • add regression coverage for case-insensitive lookup, missing instructions, empty circuits, and ignoring result types

Closes #1235.

Validation

  • .venv/bin/python -m pytest test/unit_tests/braket/circuits/test_circuit.py -q
  • .venv/bin/python -m ruff check src/braket/circuits/circuit.py
  • .venv/bin/python -m ruff format --check src/braket/circuits/circuit.py test/unit_tests/braket/circuits/test_circuit.py
  • git diff --check

Note: running ruff check on the full existing test_circuit.py with the latest local ruff surfaces many pre-existing findings unrelated to this PR, so I scoped lint to the changed source file and used format checking for both touched files.

AI use

I used an AI coding assistant to inspect the existing circuit API, implement the small method and tests, and run validation. I reviewed the final diff before submission.

@yanziwei yanziwei requested a review from a team as a code owner June 11, 2026 11:24
@yanziwei yanziwei changed the title Add Circuit instruction counting feat: add Circuit instruction counting Jun 11, 2026
@yanziwei yanziwei force-pushed the circuit-instruction-count branch from ffa62cc to 327c8d6 Compare June 11, 2026 11:28
@veena-vee989

Copy link
Copy Markdown

@yanziwei (cc @sesmart)

Hello - you are currently over the PR limit for unitaryHACK, so your PRs will be disregarded until you align with the rules. Reach out to hack@unitary.foundation to be reinstated. (PR 2 of 7)

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

2 participants