diff --git a/abp/graphstate.py b/abp/graphstate.py index 31fc891..baa1c9d 100755 --- a/abp/graphstate.py +++ b/abp/graphstate.py @@ -49,7 +49,7 @@ class GraphState(object): self._add_node(self, *args, **kwargs) def _del_node(self, node): - """ Remove a node. TODO: this is a hack right now! """ + """ Remove a node. TODO: this is a hack right now. """ if not node in self.node: return del self.node[node] @@ -57,6 +57,10 @@ class GraphState(object): del self.adj[k][node] del self.adj[node] + def del_qubit(self, node): + """ Remove a qubit. TODO: this is a hack right now. """ + self._del_node(node) + def _add_node(self, node, **kwargs): """ Add a node. By default, nodes are initialized with ``vop=``:math:`I`, i.e. they are in the :math:`|+\\rangle` state. @@ -424,8 +428,7 @@ class GraphState(object): """ Represent as a string for quick debugging """ s = "" for key in sorted(self.node.keys()): - s += "{}: {}\t".format( - key, clifford.get_name(self.node[key]["vop"]).replace("YC", "-")) + s += "{}: {}\t".format(key, clifford.get_name(self.node[key]["vop"])) if self.adj[key]: s += str(tuple(self.adj[key].keys())).replace(" ", "") else: diff --git a/abp/qi.py b/abp/qi.py index 30db417..4d760f5 100644 --- a/abp/qi.py +++ b/abp/qi.py @@ -123,10 +123,18 @@ class CircuitModel(object): b = normalize_global_phase(other.state) return np.allclose(a, b) + def __setitem__(self, key, value): + """ Set a matrix element """ + self.state[key] = value + + def __getitem__(self, key): + """ Get a matrix element """ + return self.state[key] + def __str__(self): s = "" for i in range(self.d): - label = bin(i)[2:].rjust(self.nqubits, "0") + label = bin(i)[2:].rjust(self.nqubits, "0")[::-1] if abs(self.state[i, 0]) > 0.00001: term = self.state[i, 0] real_sign = " " if term.real>=0 else "-" diff --git a/abp/static/index.html b/abp/static/index.html index b9ceaa3..36c66ed 100644 --- a/abp/static/index.html +++ b/abp/static/index.html @@ -25,7 +25,7 @@ -
Version 0.4.20 develop mode
+
Version 0.4.20