XanaduAI / MrMustard

A differentiable bridge between phase space and Fock space
https://mrmustard.readthedocs.io/
Apache License 2.0
78 stars 25 forks source link

DM probabilities bug fix #474

Closed apchytr closed 1 month ago

apchytr commented 1 month ago

Context: Currently on develop we see the following

(mrml.Vacuum([0,1]) >> mrml.Number([0], 1).dual).probability
>> 0.0

(mrml.Vacuum([0,1]) >> mrml.Number([0], 1).dual).dm().probability
>> 1.0

thanks to @kaspernielsen96 for pointing out that it's due to the polynomial wires.

Description of the Change: Bargmann.scalar now handles the logic for polynomial wires. As a result, the above no longer occurs. Additionally, .dm() on DM and cleanup reordering states/base.py.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.55172% with 4 lines in your changes missing coverage. Please review.

Project coverage is 89.47%. Comparing base (8a40c68) to head (bdaee34). Report is 2 commits behind head on develop.

Files Patch % Lines
mrmustard/lab_dev/states/base.py 96.42% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #474 +/- ## =========================================== + Coverage 89.34% 89.47% +0.13% =========================================== Files 102 102 Lines 7262 7365 +103 =========================================== + Hits 6488 6590 +102 - Misses 774 775 +1 ``` | [Files](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) | Coverage Δ | | |---|---|---| | [mrmustard/lab\_dev/circuit\_components.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuit_components.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdF9jb21wb25lbnRzLnB5) | `99.36% <100.00%> (+0.94%)` | :arrow_up: | | [mrmustard/physics/representations.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?src=pr&el=tree&filepath=mrmustard%2Fphysics%2Frepresentations.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL3BoeXNpY3MvcmVwcmVzZW50YXRpb25zLnB5) | `98.65% <100.00%> (+0.46%)` | :arrow_up: | | [mrmustard/lab\_dev/states/base.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fstates%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvc3RhdGVzL2Jhc2UucHk=) | `96.13% <96.42%> (-0.29%)` | :arrow_down: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Last update [d2b8466...bdaee34](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/474?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI).