浏览代码

Fix examples, improve robustness.

master
Pete Shadbolt 8 年前
父节点
当前提交
6a8b1a9ceb
共有 3 个文件被更改,包括 13 次插入6 次删除
  1. +10
    -5
      abp/static/scripts/graph.js
  2. +1
    -0
      examples/visualization/lattice_2d.py
  3. +2
    -1
      examples/visualization/lattice_3d.py

+ 10
- 5
abp/static/scripts/graph.js 查看文件

@@ -50,11 +50,16 @@ graph.update = function(newState) {
if (editor.selection) {
console.log(editor.selection);
var node = editor.selection;
editor.grid.position.copy(abj.node[node].position);
gui.controls.target.copy(abj.node[node].position);
node_name.innerHTML = "Node " + node;
node_data.className = "visible";
node_vop.innerHTML = "VOP: " + abj.node[node].vop;
if (Object.prototype.hasOwnProperty.call(abj.node, node)) {
editor.grid.position.copy(abj.node[node].position);
gui.controls.target.copy(abj.node[node].position);
node_name.innerHTML = "Node " + node;
node_data.className = "visible";
node_vop.innerHTML = "VOP: " + abj.node[node].vop;
} else {
editor.selection = undefined;
node_data.className = "hidden";
}
} else {
node_data.className = "hidden";
}


+ 1
- 0
examples/visualization/lattice_2d.py 查看文件

@@ -40,4 +40,5 @@ for node in nodes:

for edge in edges:
psi.act_cz(str(edge[0]), str(edge[1]))
psi.update(0.1)


+ 2
- 1
examples/visualization/lattice_3d.py 查看文件

@@ -45,9 +45,10 @@ nodes, edges = lattice(threedee_unit_cell, (3, 3, 3))

psi = GraphState()
for node in nodes:
psi.add_node(str(node), position=xyz(*node))
psi.add_qubit(str(node), position=xyz(*node))
psi.act_hadamard(str(node))

for edge in edges:
psi.act_cz(str(edge[0]), str(edge[1]))
psi.update()


正在加载...
取消
保存