Skip to content

Commit e5c02ce

Browse files
apchytrziofil
andauthored
Representation + Wires refactor (#498)
**Context:** One bottleneck currently in Mr Mustard is that `Representation` and `Wires` are treated separately when they are in fact very closely related. Here is presented an alternative implementation based on the [Merging Representation and Ansatz](#487) PR. In this, we now have a single `Representation` class that contains the ansatz, the wires and a dictionary mapping wires to their respective representation. To consider: Remove ArrayAnsatz and only use PolyExp? **Description of the Change:** - Introduced the new `Representation` class. - Introduced `RepEnum` class. - What is currently on develop as Ansatz and Representation is replaced with just Ansatz. - All `CircuitComponents` are initialized with a `Representation` and a name. Exposed classes are still initialized with modes where they make use of the new `from_modes` class method. - Renamed bargmann.py and fock.py to bargmann_utils.py and fock_utils.py - Renamed `fock` to `fock_array` **Benefits:** We now have an object responsible for managing multi representations and keeping track of what wire each representation is. Fewer classes to maintain (6 -> 4). Clearer separation of responsibilities. Much cleaner codebase. --------- Co-authored-by: Filippo Miatto <[email protected]>
1 parent 43d1855 commit e5c02ce

File tree

108 files changed

+3479
-3789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3479
-3789
lines changed

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ coverage:
55
target: 89%
66
patch:
77
default:
8-
target: auto
8+
target: 99%
99
threshold: 0%

.github/workflows/tests_docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ jobs:
3939
- name: Run tests
4040
run: |
4141
python -m pytest --doctest-modules mrmustard/math/parameter_set.py
42-
python -m pytest --doctest-modules mrmustard/physics/ansatze.py
43-
python -m pytest --doctest-modules mrmustard/physics/representations.py
42+
python -m pytest --doctest-modules mrmustard/physics/ansatz
4443
python -m pytest --doctest-modules mrmustard/lab_dev

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ ignored-classes=numpy,tensorflow,scipy,networkx,strawberryfields,thewalrus
2828
# can either give multiple identifier separated by comma (,) or put this option
2929
# multiple time (only on the command line, not in the configuration file where
3030
# it should appear only once).
31-
disable=fixme,no-member,line-too-long,invalid-name,too-many-lines,redefined-builtin,too-many-locals,duplicate-code,too-many-arguments,too-few-public-methods,no-else-return,isinstance-second-argument-not-valid-type,no-self-argument, arguments-differ
31+
disable=fixme,no-member,line-too-long,invalid-name,too-many-lines,redefined-builtin,too-many-locals,duplicate-code,too-many-arguments,too-few-public-methods,no-else-return,isinstance-second-argument-not-valid-type,no-self-argument, arguments-differ, protected-access

doc/code/lab_dev.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mrmustard.lab_dev
44
.. toctree::
55
:maxdepth: 1
66

7-
lab_dev/wires
87
lab_dev/circuit_components
98
lab_dev/states
109
lab_dev/transformations

doc/code/lab_dev/wires.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/code/physics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mrmustard.physics
44
.. toctree::
55
:maxdepth: 1
66

7-
physics/ansatze
7+
physics/wires
88
physics/representations
99

1010
.. toctree::

doc/code/physics/ansatze.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Calculations on Bargmann objects
22
================================
33

4-
.. currentmodule:: mrmustard.physics.bargmann
4+
.. currentmodule:: mrmustard.physics.bargmann_utils
55

6-
.. automodapi:: mrmustard.physics.bargmann
6+
.. automodapi:: mrmustard.physics.bargmann_utils
77
:no-heading:
88
:include-all-objects:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Calculations on Fock objects
22
============================
33

4-
.. currentmodule:: mrmustard.physics.fock
4+
.. currentmodule:: mrmustard.physics.fock_utils
55

6-
.. automodapi:: mrmustard.physics.fock
6+
.. automodapi:: mrmustard.physics.fock_utils
77
:no-heading:
88
:include-all-objects:

doc/code/physics/wires.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mrmustard.physics.wires
2+
=======================
3+
4+
.. currentmodule:: mrmustard.physics.wires
5+
6+
.. automodapi:: mrmustard.physics.wires
7+
:no-heading:
8+
:include-all-objects:

0 commit comments

Comments
 (0)