Skip to content

fix: use tracking-based is_mcm_dependent in AbstractProgramContext#366

Closed
rmshaffer wants to merge 4 commits into
mainfrom
rmshaffer/context
Closed

fix: use tracking-based is_mcm_dependent in AbstractProgramContext#366
rmshaffer wants to merge 4 commits into
mainfrom
rmshaffer/context

Conversation

@rmshaffer
Copy link
Copy Markdown
Contributor

@rmshaffer rmshaffer commented Apr 28, 2026

Issue #, if available:

Description of changes:

AbstractProgramContext.is_mcm_dependent now uses the scope-tracking machinery that already exists on the base class (_mcm_dependent_scopes, _is_name_mcm_dependent, _referenced_identifiers). The identical override on ProgramContext is removed.

Subclasses that use a different tracking model (e.g.qiskit-braket-provider's _QiskitProgramContext, which tracks measured bits in its own set) should override is_mcm_dependent to reflect that model. A companion change in qiskit-braket-provider does exactly this.

Testing done:

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.

@rmshaffer rmshaffer requested a review from a team as a code owner April 28, 2026 18:59
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #366   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         4894      4895    +1     
  Branches       565       565           
=========================================
+ Hits          4894      4895    +1     

☔ View full report in Codecov by Sentry.
📢 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.

@rmshaffer rmshaffer requested a review from speller26 April 28, 2026 19:14
Comment thread src/braket/default_simulator/openqasm/program_context.py Outdated
@speller26
Copy link
Copy Markdown
Member

Implemented a different fix in #367

@rmshaffer rmshaffer marked this pull request as draft April 29, 2026 01:03
@rmshaffer rmshaffer changed the title fix: safe defaults in AbstractProgramContext for downstream contexts fix: use tracking-based is_mcm_dependent in AbstractProgramContext Apr 29, 2026
None: Signals the Interpreter to evaluate the expression once.
"""
raise NotImplementedError
yield
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually originally had this default, but decided against it because I don't want the abstract class to bias towards an implementation (in this case translation)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense. Happy to close this PR in favor of #367

@rmshaffer rmshaffer closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants