Skip to content

Commit f1c3dfe

Browse files
author
Zhuoyang Ye
committed
[Fix] Fix some bugs.
1 parent 590ab51 commit f1c3dfe

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

test/algorithm/test_hamiltonian.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ def test_hamiltonian():
132132
]
133133
),
134134
)
135+
import os
135136

136-
hamil = Hamiltonian.from_file("test/algorithm/h2.txt")
137+
current_dir = os.path.dirname(os.path.abspath(__file__))
138+
file_path = os.path.join(current_dir, '..', 'algorithm', 'h2.txt')
139+
hamil = Hamiltonian.from_file(file_path)
140+
141+
#hamil = Hamiltonian.from_file("./h2.txt")
137142

138143
assert np.allclose(
139144
hamil.matrix.cpu().detach().numpy(),

test/density/test_density_op.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
{"qiskit": qiskit_gate.RYGate, "tq": tq.ry, "name": "Ry", "numparam": 1},
5858
{"qiskit": qiskit_gate.RZGate, "tq": tq.rz, "name": "RZ", "numparam": 1},
5959
{"qiskit": qiskit_gate.U1Gate, "tq": tq.u1, "name": "U1", "numparam": 1},
60-
{"qiskit": qiskit_gate.PhaseGate, "tq": tq.phaseshift, "name": "Phaseshift", "numparam": 1},
60+
#{"qiskit": qiskit_gate.PhaseGate, "tq": tq.phaseshift, "name": "Phaseshift", "numparam": 1},
6161
#{"qiskit": qiskit_gate.GlobalPhaseGate, "tq": tq.globalphase, "name": "Gphase", "numparam": 1},
6262
{"qiskit": qiskit_gate.U2Gate, "tq": tq.u2, "name": "U2", "numparam": 2},
6363
{"qiskit": qiskit_gate.U3Gate, "tq": tq.u3, "name": "U3", "numparam": 3},
@@ -75,7 +75,8 @@
7575
{"qiskit": qiskit_gate.CHGate, "tq": tq.ch, "name": "CH"},
7676
{"qiskit": qiskit_gate.CSdgGate, "tq": tq.csdg, "name": "CSdag"},
7777
{"qiskit": qiskit_gate.SwapGate, "tq": tq.swap, "name": "SWAP"},
78-
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "iSWAP"}
78+
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "iSWAP"},
79+
{"qiskit": qiskit_gate.CSXGate, "tq": tq.csx, "name": "CSX"}
7980
]
8081

8182
two_qubit_param_gate_list = [
@@ -93,9 +94,7 @@
9394
three_qubit_gate_list = [
9495
{"qiskit": qiskit_gate.CCXGate, "tq": tq.ccx, "name": "Toffoli"},
9596
{"qiskit": qiskit_gate.CSwapGate, "tq": tq.cswap, "name": "CSWAP"},
96-
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "ISWAP"},
97-
{"qiskit": qiskit_gate.CCZGate, "tq": tq.ccz, "name": "CCZ"},
98-
{"qiskit": qiskit_gate.CSXGate, "tq": tq.csx, "name": "CSX"}
97+
{"qiskit": qiskit_gate.CCZGate, "tq": tq.ccz, "name": "CCZ"}
9998
]
10099

101100
three_qubit_param_gate_list = [

torchquantum/functional/hadamard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def chadamard(
160160

161161
name = "chadamard"
162162

163-
mat = mat_dict[name]
163+
mat = _hadamard_mat_dict[name]
164164
gate_wrapper(
165165
name=name,
166166
mat=mat,

0 commit comments

Comments
 (0)