TeamGraphix / graphix

measurement-based quantum computing (MBQC) compiler and simulator
https://graphix.readthedocs.io
Apache License 2.0
60 stars 21 forks source link

New classes for commands and instructions #155

Closed benjvmin93 closed 2 months ago

benjvmin93 commented 4 months ago

Before submitting, please check the following:

Then, please fill in below:

Context (if applicable):

Description of the change: Introduced class Command and class Instruction for readability, maintainability and data validation purposes.

These classes allow to get rid of the list representation of both circuit model instructions, and the pattern commands. They are implemented using pydantic, which allows to validate the datas passed to the classes during instanciation.

Related issue:

also see that checks (github actions) pass. If lint check keeps failing, try installing black==22.8.0 as behavior seems to vary across versions.

shinich1 commented 3 months ago

@thierry-martinez could you resolve the above comments if think they're already taken care of (if not, please leave them open)?

shinich1 commented 3 months ago

great work @benjvmin93 and sorry for the delay reviewing this. I added various comments. Let us aim to merge this after #135 is merged (should be very soon).

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 89.01734% with 114 lines in your changes missing coverage. Please review.

Project coverage is 72.44%. Comparing base (cef611d) to head (aacc569).

:exclamation: Current head aacc569 differs from pull request most recent head aba3ebb

Please upload reports for the commit aba3ebb to get more accurate results.

Files Patch % Lines
graphix/pattern.py 78.61% 74 Missing :warning:
graphix/visualization.py 0.00% 13 Missing :warning:
graphix/transpiler.py 97.57% 10 Missing :warning:
graphix/gflow.py 76.66% 7 Missing :warning:
graphix/simulator.py 86.66% 4 Missing :warning:
graphix/generator.py 84.61% 2 Missing :warning:
graphix/sim/tensornet.py 92.30% 2 Missing :warning:
graphix/device_interface.py 0.00% 1 Missing :warning:
graphix/sim/statevec.py 96.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #155 +/- ## ========================================== + Coverage 72.25% 72.44% +0.19% ========================================== Files 32 32 Lines 5485 5477 -8 ========================================== + Hits 3963 3968 +5 + Misses 1522 1509 -13 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

EarlMilktea commented 2 months ago

@benjvmin93 @thierry-martinez

Great job!

I will submit small PRs directly to your fork later.

EarlMilktea commented 2 months ago

MEMO: Usage of abc.ABC may need refactor later.

thierry-martinez commented 2 months ago

I think it is all green now: @shinich1, what do you think? Could @benjvmin93 merge the PR?

shinich1 commented 2 months ago

@benjvmin93 @thierry-martinez great, please squash and merge.