Repository: Agony5757/QPanda-lite (language: python)

Issue:
[feat] Noisy Simulator random seed
The output of the noisy simulator under the same circuit will return the same sampling output.

It should return another similar output. @YunJ1e 


Discussion / hints:

Fix patch:
diff --git a/QPandaLiteCpp/Pybinder/QPandaLitePy.cpp b/QPandaLiteCpp/Pybinder/QPandaLitePy.cpp
index 03f718d..cbb6b70 100644
--- a/QPandaLiteCpp/Pybinder/QPandaLitePy.cpp
+++ b/QPandaLiteCpp/Pybinder/QPandaLitePy.cpp
@@ -117,10 +117,11 @@ PYBIND11_MODULE(QPandaLitePy, m)
 		.def_readonly("noise", &qpandalite::NoisySimulator::noise)
 		.def_readonly("measurement_error_matrices", &qpandalite::NoisySimulator::measurement_error_matrices)
 		.def("load_opcode", &qpandalite::NoisySimulator::load_opcode)
-		.def("insert_error", &qpandalite::NoisySimulator::insert_error)
-		.def("id", &qpandalite::NoisySimulator::id, py::arg("qn"), py::arg("is_dagger") = false)		.def("get_measure_no_readout_error", &qpandalite::NoisySimulator::get_measure_no_readout_error)
+		.def("insert_error", &qpandalite::NoisySimulator::insert_error)	
+		.def("get_measure_no_readout_error", &qpandalite::NoisySimulator::get_measure_no_readout_error)
 		.def("get_measure", &qpandalite::NoisySimulator::get_measure)
-
+		
+		.def("id", &qpandalite::NoisySimulator::id, py::arg("qn"), py::arg("is_dagger") = false)
 		.def("hadamard", &qpandalite::NoisySimulator::hadamard, py::arg("qn"), py::arg("dagger") = false)
 		.def("u22", &qpandalite::NoisySimulator::u22, py::arg("qn"), py::arg("unitary"), py::arg("dagger") = false)
 		.def("x", &qpandalite::NoisySimulator::x, py::arg("qn"), py::arg("dagger") = false)


Test patch:
diff --git a/qpandalite/test/test_general.py b/qpandalite/test/test_general.py
index f201f3e..a20daa8 100644
--- a/qpandalite/test/test_general.py
+++ b/qpandalite/test/test_general.py
@@ -1,7 +1,11 @@
 import qpandalite
 import qpandalite.simulator as qsim
+import numpy as np
+
+import qpandalite.simulator as sim
+from qpandalite.qasm_origin import OpenQASM2_Parser
+from qpandalite.circuit_builder import Circuit
 
-import numpy
 
 def iswap_test():
     sim = qsim.Simulator()
diff --git a/qpandalite/test/test_originir_parser.py b/qpandalite/test/test_originir_parser.py
index 877c56e..6403f82 100644
--- a/qpandalite/test/test_originir_parser.py
+++ b/qpandalite/test/test_originir_parser.py
@@ -1,4 +1,46 @@
 import qpandalite
+import qpandalite.simulator as qsim
+import numpy as np
+
+import qpandalite.simulator as sim
+from qpandalite.qasm_origin import OpenQASM2_Parser
+from qpandalite.circuit_builder import Circuit
 
 def run_test_originir_parser():
-    pass
\ No newline at end of file
+    pass
+
+def barrier_test():
+    circ = QuantumCircuit(3)
+    circ.h(0)
+    circ.barrier(0)
+    circ.rx(-0.4, 0)
+    circ.barrier(1)
+    circ.x(0)
+    circ.barrier(2)
+    circ.ry(0.4, 0)
+    circ.barrier(0, 1)
+    circ.y(0)
+    circ.barrier(1, 2)
+    circ.rz(np.pi/3, 1)
+    circ.barrier(0, 1, 2)
+    circ.z(0)
+    circ.cz(0, 1)
+    circ.cx(0, 2)
+    meas = QuantumCircuit(3, 3)
+    meas.measure(range(3), range(3))
+    circ = meas.compose(circ, range(3), front=True)
+    qasm_string = circ.qasm()
+    # print("---Circuit created using Qiskit(QASM)---")
+    # print(qasm_string)
+    # Create a Circuit instance from the QASM string
+    circuit_origin = OpenQASM2_Parser.build_from_qasm_str(qasm_string)
+    # print("---OriginIR Circuit coverted from QASM---")
+    # print(circuit_origin.circuit)
+
+    origin_qc = QuantumCircuit.from_qasm_str(circuit_origin.qasm)
+    # print("---Back?---")
+
+    return origin_qc.qasm() == qasm_string
+
+if __name__ == '__main__':
+    barrier_test()
\ No newline at end of file
diff --git a/test/qpandalite/circuit_builder/test_barrier.py b/test/qpandalite/circuit_builder/test_barrier.py
index 2e5fcda..4d498a6 100644
--- a/test/qpandalite/circuit_builder/test_barrier.py
+++ b/test/qpandalite/circuit_builder/test_barrier.py
@@ -37,4 +37,5 @@
 
 origin_qc = QuantumCircuit.from_qasm_str(circuit_origin.qasm)
 print("---Back?---")
-print(origin_qc.qasm())
\ No newline at end of file
+
+print(origin_qc.qasm() == qasm_string)
\ No newline at end of file