Skip to content

feature: count circuit instructions#1287

Open
jamilahmadzai wants to merge 1 commit into
amazon-braket:mainfrom
jamilahmadzai:feature/circuit-count-1235
Open

feature: count circuit instructions#1287
jamilahmadzai wants to merge 1 commit into
amazon-braket:mainfrom
jamilahmadzai:feature/circuit-count-1235

Conversation

@jamilahmadzai

Copy link
Copy Markdown

Issue #, if available:
Closes #1235

Description of changes:
Adds Circuit.count() for instruction operator counts. It returns the case-insensitive count for a requested operator, for example circuit.count("cnot"), and returns counts for all operators when no operator is provided. It can also limit counts to instructions touching a requested target qubit set.

Testing done:

  • uv run --extra test python -m pytest -n 0 test/unit_tests/braket/circuits/test_circuit.py
  • uv run --with ruff ruff check src/braket/circuits/circuit.py
  • git diff --check

unitaryHACK:

  • Registered GitHub user: @jamilahmadzai
  • Payout: unitaryHACK event registration for @jamilahmadzai; no PR-specific public wallet/payment rail is requested in the issue.
  • Tooling disclosure: LLM assistance was used while preparing this patch; the final diff and validation are included above.

Merge Checklist

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.

@jamilahmadzai jamilahmadzai requested a review from a team as a code owner June 6, 2026 11:50
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a5ee47d) to head (aad5c85).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1287   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          169       169           
  Lines        10963     10969    +6     
  Branches      1412      1413    +1     
=========================================
+ Hits         10963     10969    +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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