Skip to content

Commit

Permalink
[Fix] Fix some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoyang Ye committed Feb 26, 2024
1 parent 590ab51 commit f1c3dfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion test/algorithm/test_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ def test_hamiltonian():
]
),
)
import os

hamil = Hamiltonian.from_file("test/algorithm/h2.txt")
current_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(current_dir, '..', 'algorithm', 'h2.txt')
hamil = Hamiltonian.from_file(file_path)

#hamil = Hamiltonian.from_file("./h2.txt")

assert np.allclose(
hamil.matrix.cpu().detach().numpy(),
Expand Down
9 changes: 4 additions & 5 deletions test/density/test_density_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{"qiskit": qiskit_gate.RYGate, "tq": tq.ry, "name": "Ry", "numparam": 1},
{"qiskit": qiskit_gate.RZGate, "tq": tq.rz, "name": "RZ", "numparam": 1},
{"qiskit": qiskit_gate.U1Gate, "tq": tq.u1, "name": "U1", "numparam": 1},
{"qiskit": qiskit_gate.PhaseGate, "tq": tq.phaseshift, "name": "Phaseshift", "numparam": 1},
#{"qiskit": qiskit_gate.PhaseGate, "tq": tq.phaseshift, "name": "Phaseshift", "numparam": 1},
#{"qiskit": qiskit_gate.GlobalPhaseGate, "tq": tq.globalphase, "name": "Gphase", "numparam": 1},
{"qiskit": qiskit_gate.U2Gate, "tq": tq.u2, "name": "U2", "numparam": 2},
{"qiskit": qiskit_gate.U3Gate, "tq": tq.u3, "name": "U3", "numparam": 3},
Expand All @@ -75,7 +75,8 @@
{"qiskit": qiskit_gate.CHGate, "tq": tq.ch, "name": "CH"},
{"qiskit": qiskit_gate.CSdgGate, "tq": tq.csdg, "name": "CSdag"},
{"qiskit": qiskit_gate.SwapGate, "tq": tq.swap, "name": "SWAP"},
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "iSWAP"}
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "iSWAP"},
{"qiskit": qiskit_gate.CSXGate, "tq": tq.csx, "name": "CSX"}
]

two_qubit_param_gate_list = [
Expand All @@ -93,9 +94,7 @@
three_qubit_gate_list = [
{"qiskit": qiskit_gate.CCXGate, "tq": tq.ccx, "name": "Toffoli"},
{"qiskit": qiskit_gate.CSwapGate, "tq": tq.cswap, "name": "CSWAP"},
{"qiskit": qiskit_gate.iSwapGate, "tq": tq.iswap, "name": "ISWAP"},
{"qiskit": qiskit_gate.CCZGate, "tq": tq.ccz, "name": "CCZ"},
{"qiskit": qiskit_gate.CSXGate, "tq": tq.csx, "name": "CSX"}
{"qiskit": qiskit_gate.CCZGate, "tq": tq.ccz, "name": "CCZ"}
]

three_qubit_param_gate_list = [
Expand Down
2 changes: 1 addition & 1 deletion torchquantum/functional/hadamard.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def chadamard(

name = "chadamard"

mat = mat_dict[name]
mat = _hadamard_mat_dict[name]
gate_wrapper(
name=name,
mat=mat,
Expand Down

0 comments on commit f1c3dfe

Please sign in to comment.