Browse Source

Test passing

Pete Shadbolt 5 months ago
parent
commit
290780787f
3 changed files with 2 additions and 47 deletions
  1. 2
    1
      abp/graphstate.py
  2. 0
    1
      examples/visualization/raussendorf.py
  3. 0
    45
      tests/test_nx.py

+ 2
- 1
abp/graphstate.py View File

@@ -30,7 +30,8 @@ class GraphState(object):
30 30
         :param vop: The default VOP for new qubits. Setting ``vop="identity"`` initializes qubits in :math:`|+\\rangle`. Setting ``vop="hadamard"`` initializes qubits in :math:`|0\\rangle`.
31 31
         """
32 32
 
33
-        self.adj, self.node = {}, {}
33
+        self.adj = {}
34
+        self.node = {}
34 35
         self.url = None
35 36
         try:
36 37
             # Cloning from a networkx graph

+ 0
- 1
examples/visualization/raussendorf.py View File

@@ -49,7 +49,6 @@ psi = GraphState()
49 49
 for node in nodes:
50 50
     x, y, z = node
51 51
     color = "red" if (x+y+z) % 2 > 0  else "black"
52
-    print(color)
53 52
     psi.add_qubit(node, position=xyz(*node), color=color)
54 53
     psi.act_hadamard(node)
55 54
 

+ 0
- 45
tests/test_nx.py View File

@@ -1,45 +0,0 @@
1
-import json
2
-import networkx as nx
3
-from abp import GraphState, NXGraphState
4
-from abp import clifford
5
-from abp.util import xyz
6
-import mock
7
-
8
-
9
-def test_json_basic():
10
-    """ Test that we can export to JSON """
11
-    g = mock.simple_graph()
12
-    js = g.to_json()
13
-    assert "adj" in js
14
-    assert "node" in js
15
-
16
-
17
-def test_tuple_keys():
18
-    """ Test that we can use tuple-ish keys """
19
-    g = NXGraphState()
20
-    g.add_qubit("string")
21
-    g.add_qubit((1, 2, 3))
22
-    g.add_edge((1, 2, 3), "string")
23
-    json.dumps(g.to_json(True))
24
-
25
-
26
-def networkx_test():
27
-    """ Test that NXGraphStates really behave like networkx graphs """
28
-    g = NXGraphState()
29
-    g.add_qubit(0, position=xyz(10, 0, 0))
30
-    g.add_qubit(1, position=xyz(1, 0, 0))
31
-    g.act_hadamard(0)
32
-    g.act_hadamard(1)
33
-    g.act_cz(0, 1)
34
-    g.copy()
35
-
36
-
37
-def test_from_nx():
38
-    """ Test that making graphs from networkx objects goes smoothly """
39
-    g = nx.random_geometric_graph(100, 2)
40
-    psi = NXGraphState(g)
41
-    assert psi.node[0]["vop"] == 0
42
-    assert len(psi.edges()) > 0
43
-    psi.measure(0, "px", detail=True)
44
-
45
-    psi = NXGraphState(nx.Graph(((0, 1),)))