Pete Shadbolt il y a 7 ans
Parent
révision
a891510398
4 fichiers modifiés avec 22 ajouts et 9 suppressions
  1. +3
    -3
      abp/graphstate.py
  2. +13
    -0
      abp/static/main.css
  3. +1
    -1
      abp/static/scripts/materials.js
  4. +5
    -5
      tests/mock.py

+ 3
- 3
abp/graphstate.py Voir le fichier

@@ -99,14 +99,14 @@ class GraphState(object):
def act_circuit(self, circuit):
""" Run many gates in one call.

:param circuit: An iterable containing tuples of the form ``(node, operation)``. If ``operation`` is a name for a local operation (e.g. ``6``, ``hadamard``) then that operation is performed on ``node``. If ``operation`` is ``cz`` then a CZ is performed on the two nodes in ``node``.
:param circuit: An iterable containing tuples of the form ``(operation, node)``. If ``operation`` is a name for a local operation (e.g. ``6``, ``hadamard``) then that operation is performed on ``node``. If ``operation`` is ``cz`` then a CZ is performed on the two nodes in ``node``.

Example (makes a Bell pair)::

>>> g.act_circuit([(0, "hadamard"), (1, "hadamard"), ((0, 1), "cz")])
>>> g.act_circuit([("hadamard", 0), ("hadamard", 1), ("cz", (0, 1))])

"""
for node, operation in circuit:
for operation, node in circuit:
if operation == "cz":
self.act_cz(*node)
else:


+ 13
- 0
abp/static/main.css Voir le fichier

@@ -41,6 +41,19 @@ html, body { margin: 0; padding: 0; overflow: hidden; font-size: 10pt; font-fam
font-size: 9pt;
}

#options {
background-color: rgba(256, 256, 256, .5);
color: black;
padding: 10px;
font-family: monospace;
position: absolute;
text-align: right;
bottom: 10px;
right: 10px;
font-size: 9pt;
}


#version {
color:black;
padding: 10px;


+ 1
- 1
abp/static/scripts/materials.js Voir le fichier

@@ -12,7 +12,7 @@ materials.prepare = function() {
materials.edge = new THREE.LineBasicMaterial({
color: "gray",
transparent: false,
linewidth: 3
linewidth: 5
});
materials.edge.depthTest = false;
materials.qubit = new THREE.PointsMaterial({


+ 5
- 5
tests/mock.py Voir le fichier

@@ -39,7 +39,7 @@ class AndersWrapper(graphsim.GraphRegister):
return self.to_json() == other.to_json()

def act_circuit(self, circuit):
for node, operation in circuit:
for operation, node in circuit:
if operation == "cz":
self.act_cz(*node)
else:
@@ -103,8 +103,8 @@ def named_node_graph():
""" A graph with named nodes"""
edges = (0, 1), (1, 2), (2, 0), (0, 3), (100, 200), (200, "named")
g = ABPWrapper([0, 1, 2, 3, 100, 200, "named"])
g.act_circuit((i, "hadamard") for i in g.node)
g.act_circuit((edge, "cz") for edge in edges)
g.act_circuit(("hadamard", i) for i in g.node)
g.act_circuit(("cz", edge) for edge in edges)
return g


@@ -112,8 +112,8 @@ def simple_graph():
""" A simple graph to test with"""
edges = (0, 1), (1, 2), (2, 0), (0, 3), (100, 200)
g = ABPWrapper([0, 1, 2, 3, 100, 200])
g.act_circuit((i, "hadamard") for i in g.node)
g.act_circuit((edge, "cz") for edge in edges)
g.act_circuit(("hadamard", i) for i in g.node)
g.act_circuit(("cz", edge) for edge in edges)
return g




Chargement…
Annuler
Enregistrer