XanaduAI / MrMustard

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

try to reduce complexity of circuits.py #455

Closed timmysilv closed 3 months ago

timmysilv commented 3 months ago

Codefactor always complains of complex code due to circuits.py - I've made 3 changes:

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 90.83969% with 12 lines in your changes missing coverage. Please review.

Project coverage is 88.94%. Comparing base (d0b60a9) to head (89ee5ee).

Files Patch % Lines
mrmustard/lab_dev/circuits_utils/shapes.py 84.21% 6 Missing :warning:
mrmustard/lab_dev/circuits.py 85.00% 3 Missing :warning:
mrmustard/lab_dev/circuits_utils/indices_dict.py 90.47% 2 Missing :warning:
...ab_dev/circuit_components_utils/circuit_drawing.py 95.83% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #455 +/- ## =========================================== + Coverage 88.88% 88.94% +0.05% =========================================== Files 100 105 +5 Lines 7020 7056 +36 =========================================== + Hits 6240 6276 +36 Misses 780 780 ``` | [Files](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) | Coverage Δ | | |---|---|---| | [...stard/lab\_dev/circuit\_components\_utils/\_\_init\_\_.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuit_components_utils%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdF9jb21wb25lbnRzX3V0aWxzL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [mrmustard/lab\_dev/circuits\_utils/\_\_init\_\_.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuits_utils%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdHNfdXRpbHMvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | | | [mrmustard/lab\_dev/circuits\_utils/graph.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuits_utils%2Fgraph.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdHNfdXRpbHMvZ3JhcGgucHk=) | `100.00% <100.00%> (ø)` | | | [...ab\_dev/circuit\_components\_utils/circuit\_drawing.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuit_components_utils%2Fcircuit_drawing.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdF9jb21wb25lbnRzX3V0aWxzL2NpcmN1aXRfZHJhd2luZy5weQ==) | `95.83% <95.83%> (ø)` | | | [mrmustard/lab\_dev/circuits\_utils/indices\_dict.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuits_utils%2Findices_dict.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdHNfdXRpbHMvaW5kaWNlc19kaWN0LnB5) | `90.47% <90.47%> (ø)` | | | [mrmustard/lab\_dev/circuits.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuits.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdHMucHk=) | `95.00% <85.00%> (+2.74%)` | :arrow_up: | | [mrmustard/lab\_dev/circuits\_utils/shapes.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fcircuits_utils%2Fshapes.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvY2lyY3VpdHNfdXRpbHMvc2hhcGVzLnB5) | `84.21% <84.21%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?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/455?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Last update [d0b60a9...89ee5ee](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/455?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).
timmysilv commented 3 months ago

better ways to go about this