cda-tum / mqt-core

MQT Core - The Backbone of the Munich Quantum Toolkit
https://mqt.readthedocs.io/projects/core
MIT License
62 stars 31 forks source link

🐛 Fix dynamic circuit detection #687

Closed burgholzer closed 2 months ago

burgholzer commented 2 months ago

Description

The previous implementation of the isDynamicCircuit check would falsely report a circuit to not be dynamic if the circuit contains multiple measurements on one qubit. This PR fixes the underlying error and refactors the logic of the respective method to handle more cases.

This was discovered while working on https://github.com/cda-tum/mqt-qcec/issues/439

Checklist:

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 84.37500% with 5 lines in your changes missing coverage. Please review.

Project coverage is 87.1%. Comparing base (738d181) to head (1a30ac3). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/circuit_optimizer/CircuitOptimizer.cpp 84.3% 5 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687/graphs/tree.svg?width=650&height=150&src=pr&token=MqstsRKdqp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum)](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) ```diff @@ Coverage Diff @@ ## main #687 +/- ## ===================================== Coverage 87.1% 87.1% ===================================== Files 125 125 Lines 13781 13769 -12 Branches 2164 2156 -8 ===================================== - Hits 12005 12003 -2 + Misses 1776 1766 -10 ``` | [Flag](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | Coverage Δ | | |---|---|---| | [cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | `86.7% <84.3%> (+<0.1%)` | :arrow_up: | | [python](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | `99.7% <ø> (ø)` | | | [Files with missing lines](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum) | Coverage Δ | | |---|---|---| | [src/circuit\_optimizer/CircuitOptimizer.cpp](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687?src=pr&el=tree&filepath=src%2Fcircuit_optimizer%2FCircuitOptimizer.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum#diff-c3JjL2NpcmN1aXRfb3B0aW1pemVyL0NpcmN1aXRPcHRpbWl6ZXIuY3Bw) | `88.6% <84.3%> (+0.7%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/cda-tum/mqt-core/pull/687/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cda-tum)