index int64 0 50.7k | project_path stringclasses 279
values | completion_path stringlengths 57 199 | signature_postion stringlengths 3 11 | class_position stringlengths 3 11 | function_name stringlengths 1 62 | class_name stringlengths 0 55 | body_position stringlengths 3 11 | body_position_with_comments stringlengths 3 11 | masked_class stringlengths 14 8.32k | masked_class_with_comment stringlengths 14 8.32k | func_body stringlengths 9 6.72k | func_body_with_comment stringlengths 9 6.72k | len_func_body int64 1 643 | len_input int64 10 2.02k | len_output int64 4 1.9k | total int64 20 2.05k | file_code stringlengths 14 442k | file_code_with_comment stringlengths 14 442k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
30,428 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_7a_1.py | 28,29 | 1,42 | template_nct_7a_1 | 33,42 | 29,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(1, 0)
qc.ccx(0, 1, 2)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(1, 0)
qc.ccx(0, 1, 2)
return qc
| 21 | 430 | 123 | 553 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,429 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_7b_1.py | 28,29 | 1,42 | template_nct_7b_1 | 33,42 | 29,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.x(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.x(0)
qc.ccx(0, 1, 2)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.x(0)
qc.cx(0, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.x(0)
qc.ccx(0, 1, 2)
return qc
| 19 | 423 | 115 | 538 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,430 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_7c_1.py | 28,29 | 1,42 | template_nct_7c_1 | 33,42 | 29,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.x(0)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(0)
qc.ccx(0, 1, 2)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.x(0)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(0)
qc.ccx(0, 1, 2)
return qc
| 21 | 433 | 121 | 554 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,431 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_7d_1.py | 28,29 | 1,42 | template_nct_7d_1 | 33,42 | 29,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(1, 0)
qc.ccx(0, 1, 2)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(1, 0)
qc.ccx(0, 1, 2)
return qc
| 23 | 440 | 129 | 569 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,432 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_7e_1.py | 28,29 | 1,42 | template_nct_7e_1 | 33,42 | 29,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.x(0)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(0)
qc.cx(0, 2)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.x(0)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(0)
qc.cx(0, 2)
return qc
| 18 | 430 | 111 | 541 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,433 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9a_1.py | 28,29 | 1,44 | template_nct_9a_1 | 33,44 | 29,44 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.ccx(0, 2, 1)
qc.ccx(1, 2, 0)
qc.x(2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(1, 0)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(1, 0)
qc.ccx(0, 2, 1)
qc.ccx(1, 2, 0)
qc.x(2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(1, 0)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| 25 | 465 | 149 | 614 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,434 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_1.py | 26,27 | 1,42 | template_nct_9c_1 | 31,42 | 27,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(2)
qc.cx(1, 0)
qc.cx(0, 1)
qc.x(0)
qc.cx(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.cx(0, 1)
qc.x(1)
qc.cx(1, 0)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(2)
qc.cx(1, 0)
qc.cx(0, 1)
qc.x(0)
qc.cx(1, 0)
qc.x(1)
qc.cx(1, 0)
qc.cx(0, 1)
qc.x(1)
qc.cx(1, 0)
return qc
| 20 | 440 | 133 | 573 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,435 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_10.py | 27,28 | 1,43 | template_nct_9c_10 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| 27 | 496 | 157 | 653 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,436 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_11.py | 27,28 | 1,43 | template_nct_9c_11 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| 27 | 496 | 157 | 653 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,437 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_12.py | 27,28 | 1,43 | template_nct_9c_12 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
return qc
| 29 | 502 | 163 | 665 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,438 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_2.py | 27,28 | 1,43 | template_nct_9c_2 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| 25 | 480 | 149 | 629 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,439 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_3.py | 27,28 | 1,43 | template_nct_9c_3 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(1)
qc.cx(2, 1)
qc.x(2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(1)
qc.cx(2, 1)
qc.x(2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.cx(2, 1)
return qc
| 22 | 467 | 139 | 606 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,440 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_4.py | 27,28 | 1,43 | template_nct_9c_4 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.cx(2, 1)
return qc
| 24 | 475 | 145 | 620 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,441 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_5.py | 27,28 | 1,43 | template_nct_9c_5 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| 23 | 479 | 145 | 624 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,442 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_6.py | 27,28 | 1,43 | template_nct_9c_6 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| 25 | 488 | 151 | 639 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,443 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_7.py | 27,28 | 1,43 | template_nct_9c_7 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
return qc
| 27 | 494 | 157 | 651 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,444 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_8.py | 27,28 | 1,43 | template_nct_9c_8 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.cx(1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| 25 | 480 | 149 | 629 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,445 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9c_9.py | 27,28 | 1,43 | template_nct_9c_9 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.cx(0, 1)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 2, 1)
qc.ccx(0, 1, 2)
qc.x(2)
qc.ccx(0, 2, 1)
return qc
| 27 | 487 | 155 | 642 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,446 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_1.py | 26,27 | 1,42 | template_nct_9d_1 | 31,42 | 27,42 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cx(0, 1)
qc.cx(1, 0)
qc.x(1)
qc.cx(0, 1)
qc.cx(1, 0)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.x(1)
qc.cx(1, 0)
qc.x(1)
qc.cx(0, 1)
qc.cx(1, 0)
qc.x(1)
qc.cx(0, 1)
qc.cx(1, 0)
return qc
| 20 | 439 | 133 | 572 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,447 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_10.py | 27,28 | 1,43 | template_nct_9d_10 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
return qc
| 29 | 503 | 163 | 666 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,448 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_2.py | 27,28 | 1,43 | template_nct_9d_2 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
return qc
| 25 | 481 | 149 | 630 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,449 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_3.py | 27,28 | 1,43 | template_nct_9d_3 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.x(2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| 23 | 474 | 143 | 617 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,450 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_4.py | 27,28 | 1,43 | template_nct_9d_4 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.cx(1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.cx(1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| 23 | 480 | 145 | 625 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,451 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_5.py | 27,28 | 1,43 | template_nct_9d_5 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.cx(2, 1)
return qc
| 25 | 487 | 151 | 638 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,452 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_6.py | 27,28 | 1,43 | template_nct_9d_6 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.cx(2, 1)
return qc
| 25 | 482 | 149 | 631 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,453 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_7.py | 27,28 | 1,43 | template_nct_9d_7 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.cx(2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.cx(2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.ccx(0, 1, 2)
qc.cx(2, 1)
return qc
| 27 | 495 | 157 | 652 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,454 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_8.py | 27,28 | 1,43 | template_nct_9d_8 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
qc.cx(0, 2)
qc.cx(1, 2)
qc.ccx(0, 2, 1)
return qc
| 27 | 495 | 157 | 652 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,455 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/nct/template_nct_9d_9.py | 27,28 | 1,43 | template_nct_9d_9 | 32,43 | 28,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
return qc
| """
Returns:
QuantumCircuit: template as a quantum circuit.
"""
qc = QuantumCircuit(3)
qc.ccx(0, 1, 2)
qc.cx(0, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
qc.x(2)
qc.ccx(0, 1, 2)
qc.ccx(0, 2, 1)
return qc
| 27 | 489 | 155 | 644 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,456 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_cy.py | 31,32 | 1,47 | rzx_cy | 33,47 | 32,47 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
circ = QuantumCircuit(2)
circ.cx(0, 1)
circ.ry(theta, 1)
circ.cx(0, 1)
circ.ry(-1 * theta, 1)
circ.rz(-np.pi / 2, 1)
circ.rx(theta, 1)
circ.rzx(-1 * theta, 0, 1)
circ.rz(np.pi / 2, 1)
return circ
| """Template for CX - RYGate - CX."""
if theta is None:
theta = Parameter("ϴ")
circ = QuantumCircuit(2)
circ.cx(0, 1)
circ.ry(theta, 1)
circ.cx(0, 1)
circ.ry(-1 * theta, 1)
circ.rz(-np.pi / 2, 1)
circ.rx(theta, 1)
circ.rzx(-1 * theta, 0, 1)
circ.rz(np.pi / 2, 1)
... | 37 | 495 | 163 | 658 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,457 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_xz.py | 36,37 | 1,54 | rzx_xz | 38,54 | 37,54 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(1, 0)
qc.rx(theta, 1)
qc.cx(1, 0)
qc.rz(np.pi / 2, 0)
qc.rx(np.pi / 2, 0)
qc.rz(np.pi / 2, 0)
qc.rzx(-1 * theta, 0, 1)
qc.rz(np.pi / 2, 0)
qc.rx(np.pi / 2, 0)
qc.rz(np.pi / 2, 0)
return qc... | """Template for CX - RXGate - CX."""
if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(1, 0)
qc.rx(theta, 1)
qc.cx(1, 0)
qc.rz(np.pi / 2, 0)
qc.rx(np.pi / 2, 0)
qc.rz(np.pi / 2, 0)
qc.rzx(-1 * theta, 0, 1)
qc.rz(np.pi / 2, 0)
qc.rx(np.pi / 2,... | 47 | 581 | 218 | 799 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,458 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_yz.py | 30,31 | 1,44 | rzx_yz | 32,44 | 31,44 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
circ = QuantumCircuit(2)
circ.cx(0, 1)
circ.ry(-1 * theta, 0)
circ.cx(0, 1)
circ.rx(np.pi / 2, 0)
circ.rzx(theta, 0, 1)
circ.rx(-np.pi / 2, 0)
return circ
| """Template for CX - RYGate - CX."""
if theta is None:
theta = Parameter("ϴ")
circ = QuantumCircuit(2)
circ.cx(0, 1)
circ.ry(-1 * theta, 0)
circ.cx(0, 1)
circ.rx(np.pi / 2, 0)
circ.rzx(theta, 0, 1)
circ.rx(-np.pi / 2, 0)
return circ
| 31 | 444 | 134 | 578 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,459 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_zz1.py | 40,41 | 1,68 | rzx_zz1 | 42,68 | 41,68 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.rz(theta, 1)
qc.sx(1)
qc.rz(np.pi, 1)
qc.sx(1)
qc.rz(3 * np.pi, 1)
qc.cx(0, 1)
qc.rz(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(np.pi / 2, 1)
qc.rz(np.pi / 2, 1)
... | """Template for CX - RZGate - CX."""
if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.rz(theta, 1)
qc.sx(1)
qc.rz(np.pi, 1)
qc.sx(1)
qc.rz(3 * np.pi, 1)
qc.cx(0, 1)
qc.rz(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(n... | 65 | 747 | 323 | 1,070 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,460 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_zz2.py | 36,37 | 1,59 | rzx_zz2 | 38,59 | 37,59 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.p(theta, 1)
qc.cx(0, 1)
qc.p(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(np.pi / 2, 1)
qc.rz(np.pi / 2, 1)
qc.rx(theta, 1)
qc.rzx(-1 * theta, 0, 1)
# Hadamard
qc.rz(np... | """Template for CX - RZGate - CX."""
if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.p(theta, 1)
qc.cx(0, 1)
qc.p(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(np.pi / 2, 1)
qc.rz(np.pi / 2, 1)
qc.rx(theta, 1)
qc.rzx(-1 *... | 57 | 629 | 263 | 892 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,461 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/library/templates/rzx/rzx_zz3.py | 35,36 | 1,58 | rzx_zz3 | 37,58 | 36,58 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.rz(theta, 1)
qc.cx(0, 1)
qc.rz(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(np.pi / 2, 1)
qc.rz(np.pi / 2, 1)
qc.rx(theta, 1)
qc.rzx(-1 * theta, 0, 1)
# Hadamard
qc.rz(... | """Template for CX - RZGate - CX."""
if theta is None:
theta = Parameter("ϴ")
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.rz(theta, 1)
qc.cx(0, 1)
qc.rz(-1 * theta, 1)
# Hadamard
qc.rz(np.pi / 2, 1)
qc.rx(np.pi / 2, 1)
qc.rz(np.pi / 2, 1)
qc.rx(theta, 1)
qc.rzx(-1... | 57 | 631 | 265 | 896 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,462 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/measure.py | 33,34 | 21,45 | broadcast_arguments | Measure | 34,45 | 34,45 | class Measure(SingletonInstruction):
"""Quantum measurement in the computational basis."""
def __init__(self, label=None, *, duration=None, unit="dt"):
"""
Args:
label: optional string label for this instruction.
"""
super().__init__("measure", 1, 1, [], label=label,... | class Measure(SingletonInstruction):
"""Quantum measurement in the computational basis."""
def __init__(self, label=None, *, duration=None, unit="dt"):
"""
Args:
label: optional string label for this instruction.
"""
super().__init__("measure", 1, 1, [], label=label,... | qarg = qargs[0]
carg = cargs[0]
if len(carg) == len(qarg):
for qarg, carg in zip(qarg, carg):
yield [qarg], [carg]
elif len(qarg) == 1 and carg:
for each_carg in carg:
yield qarg, [each_carg]
else:
raise Circuit... | qarg = qargs[0]
carg = cargs[0]
if len(carg) == len(qarg):
for qarg, carg in zip(qarg, carg):
yield [qarg], [carg]
elif len(qarg) == 1 and carg:
for each_carg in carg:
yield qarg, [each_carg]
else:
raise Circuit... | 37 | 143 | 120 | 263 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,463 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/operation.py | 51,54 | 18,68 | name | Operation | 55,57 | 54,57 | class Operation(ABC):
"""Quantum operation interface.
The minimal interface that any object must fulfil in order to be added to a
:class:`.QuantumCircuit`.
Concrete instances of this interface include :class:`~qiskit.circuit.Gate`,
:class:`~qiskit.circuit.Reset`, :class:`~qiskit.circuit.Barrier`,
... | class Operation(ABC):
"""Quantum operation interface.
The minimal interface that any object must fulfil in order to be added to a
:class:`.QuantumCircuit`.
Concrete instances of this interface include :class:`~qiskit.circuit.Gate`,
:class:`~qiskit.circuit.Reset`, :class:`~qiskit.circuit.Barrier`,
... | raise NotImplementedError
| """Unique string identifier for operation type."""
raise NotImplementedError
| 2 | 457 | 11 | 468 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,464 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/parameter.py | 92,93 | 27,176 | assign | Parameter | 93,106 | 93,106 | class Parameter(ParameterExpression):
"""A compile-time symbolic parameter.
The value of a :class:`Parameter` must be entirely determined before a circuit begins execution.
Typically this will mean that you should supply values for all :class:`Parameter`\\ s in a
circuit using :meth:`.QuantumCircuit.as... | class Parameter(ParameterExpression):
"""A compile-time symbolic parameter.
The value of a :class:`Parameter` must be entirely determined before a circuit begins execution.
Typically this will mean that you should supply values for all :class:`Parameter`\\ s in a
circuit using :meth:`.QuantumCircuit.as... | if parameter != self:
# Corresponds to superclass calls to `subs` and `bind` that would implicitly set
# `allow_unknown_parameters=False`.
raise CircuitError(
f"Cannot bind Parameters ({[str(parameter)]}) not present in expression."
)
if is... | if parameter != self:
# Corresponds to superclass calls to `subs` and `bind` that would implicitly set
# `allow_unknown_parameters=False`.
raise CircuitError(
f"Cannot bind Parameters ({[str(parameter)]}) not present in expression."
)
if is... | 70 | 1,456 | 177 | 1,633 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,465 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/parametervector.py | 99,100 | 50,115 | resize | ParameterVector | 106,115 | 100,115 | class ParameterVector:
"""ParameterVector class to quickly generate lists of parameters."""
__slots__ = ("_name", "_params", "_size", "_root_uuid")
def __init__(self, name, length=0):
self._name = name
self._size = length
self._root_uuid = uuid4()
root_uuid_int = self._root... | class ParameterVector:
"""ParameterVector class to quickly generate lists of parameters."""
__slots__ = ("_name", "_params", "_size", "_root_uuid")
def __init__(self, name, length=0):
self._name = name
self._size = length
self._root_uuid = uuid4()
root_uuid_int = self._root... | if length > len(self._params):
root_uuid_int = self._root_uuid.int
self._params.extend(
[
ParameterVectorElement(self, i, UUID(int=root_uuid_int + i))
for i in range(len(self._params), length)
]
)
... | """Resize the parameter vector.
If necessary, new elements are generated. If length is smaller than before, the
previous elements are cached and not re-generated if the vector is enlarged again.
This is to ensure that the parameter instances do not change.
"""
if length ... | 24 | 521 | 97 | 618 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,466 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/parametervector.py | 30,32 | 20,50 | index | ParameterVectorElement | 33,35 | 32,35 | class ParameterVectorElement(Parameter):
"""An element of a ParameterVector."""
___slots__ = ("_vector", "_index")
def __init__(self, vector, index, uuid=None):
super().__init__(f"{vector.name}[{index}]", uuid=uuid)
self._vector = vector
self._index = index
@property
def i... | class ParameterVectorElement(Parameter):
"""An element of a ParameterVector."""
___slots__ = ("_vector", "_index")
def __init__(self, vector, index, uuid=None):
super().__init__(f"{vector.name}[{index}]", uuid=uuid)
self._vector = vector
self._index = index
@property
def i... | return self._index
| """Get the index of this element in the parent vector."""
return self._index
| 2 | 235 | 9 | 244 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,469 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/circuit/reset.py | 32,33 | 20,35 | broadcast_arguments | Reset | 33,35 | 33,35 | class Reset(SingletonInstruction):
r"""Incoherently reset a qubit to the :math:`\lvert0\rangle` state."""
def __init__(self, label=None, *, duration=None, unit="dt"):
"""
Args:
label: optional string label of this instruction.
"""
super().__init__("reset", 1, 0, [], ... | class Reset(SingletonInstruction):
r"""Incoherently reset a qubit to the :math:`\lvert0\rangle` state."""
def __init__(self, label=None, *, duration=None, unit="dt"):
"""
Args:
label: optional string label of this instruction.
"""
super().__init__("reset", 1, 0, [], ... | for qarg in qargs[0]:
yield [qarg], []
| for qarg in qargs[0]:
yield [qarg], []
| 7 | 159 | 21 | 180 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,472 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/compiler/scheduler.py | 38,46 | 1,108 | schedule | 68,108 | 46,108 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | arg_circuits_list = isinstance(circuits, list)
start_time = time()
if backend and getattr(backend, "version", 0) > 1:
if inst_map is None:
inst_map = backend.instruction_schedule_map
if meas_map is None:
meas_map = backend.meas_map
if dt is None:
d... | """
Schedule a circuit to a pulse ``Schedule``, using the backend, according to any specified
methods. Supported methods are documented in :py:mod:`qiskit.scheduler.schedule_circuit`.
Args:
circuits: The quantum circuit or circuits to translate
backend: A backend instance, which contain... | 151 | 792 | 464 | 1,256 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,473 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/compiler/sequencer.py | 26,33 | 1,70 | sequence | 53,70 | 33,70 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if inst_map is None:
if backend is None:
raise QiskitError("Must supply either a backend or inst_map for sequencing.")
inst_map = backend.defaults().instruction_schedule_map
if meas_map is None:
if backend is None:
raise QiskitError("Must supply either a backend o... | """
Schedule a scheduled circuit to a pulse ``Schedule``, using the backend.
Args:
scheduled_circuits: Scheduled circuit(s) to be translated
backend: A backend instance, which contains hardware-specific data required for scheduling
inst_map: Mapping of circuit operations to pulse sc... | 94 | 609 | 265 | 874 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,475 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/circuit_to_dag.py | 19,20 | 1,104 | circuit_to_dag | 59,104 | 20,104 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | dagcircuit = DAGCircuit()
dagcircuit.name = circuit.name
dagcircuit.global_phase = circuit.global_phase
dagcircuit.calibrations = circuit.calibrations
dagcircuit.metadata = circuit.metadata
if qubit_order is None:
qubits = circuit.qubits
elif len(qubit_order) != circuit.num_qubits o... | """Build a :class:`.DAGCircuit` object from a :class:`.QuantumCircuit`.
Args:
circuit (QuantumCircuit): the input circuit.
copy_operations (bool): Deep copy the operation objects
in the :class:`~.QuantumCircuit` for the output :class:`~.DAGCircuit`.
This should only be s... | 128 | 754 | 569 | 1,323 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | |
30,476 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/circuit_to_dagdependency.py | 18,19 | 1,52 | circuit_to_dagdependency | 29,52 | 19,52 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | dagdependency = DAGDependency()
dagdependency.name = circuit.name
dagdependency.metadata = circuit.metadata
dagdependency.add_qubits(circuit.qubits)
dagdependency.add_clbits(circuit.clbits)
for register in circuit.qregs:
dagdependency.add_qreg(register)
for register in circuit.cre... | """Build a ``DAGDependency`` object from a :class:`~.QuantumCircuit`.
Args:
circuit (QuantumCircuit): the input circuit.
create_preds_and_succs (bool): whether to construct lists of
predecessors and successors for every node.
Return:
DAGDependency: the DAG representing ... | 37 | 305 | 239 | 544 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,477 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/circuit_to_dagdependency_v2.py | 18,19 | 1,48 | _circuit_to_dagdependency_v2 | 27,48 | 19,48 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | dagdependency = _DAGDependencyV2()
dagdependency.name = circuit.name
dagdependency.metadata = circuit.metadata
dagdependency.calibrations = circuit.calibrations
dagdependency.global_phase = circuit.global_phase
dagdependency.add_qubits(circuit.qubits)
dagdependency.add_clbits(circuit.clbits... | """Build a ``_DAGDependencyV2`` object from a :class:`~.QuantumCircuit`.
Args:
circuit (QuantumCircuit): the input circuit.
Return:
_DAGDependencyV2: the DAG representing the input circuit as a dag dependency.
"""
dagdependency = _DAGDependencyV2()
dagdependency.name = circuit.... | 38 | 278 | 219 | 497 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,478 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/dag_to_circuit.py | 19,20 | 1,82 | dag_to_circuit | 56,82 | 20,82 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
name = dag.name or None
circuit = QuantumCircuit(
dag.qubits,
dag.clbits,
*dag.qregs.values(),
*dag.cregs.values(),
name=name,
global_phase=dag.global_phase,
inputs=dag.iter_input_vars(),
captures=dag.iter_captured_vars(),
)
for var in dag... | """Build a ``QuantumCircuit`` object from a ``DAGCircuit``.
Args:
dag (DAGCircuit): the input dag.
copy_operations (bool): Deep copy the operation objects
in the :class:`~.DAGCircuit` for the output :class:`~.QuantumCircuit`.
This should only be set to ``False`` if the i... | 51 | 668 | 274 | 942 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | |
30,479 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/dag_to_dagdependency.py | 17,18 | 1,56 | dag_to_dagdependency | 28,56 | 18,56 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
dagdependency = DAGDependency()
dagdependency.name = dag.name
dagdependency.metadata = dag.metadata
dagdependency.add_qubits(dag.qubits)
dagdependency.add_clbits(dag.clbits)
for register in dag.qregs.values():
dagdependency.add_qreg(register)
for register in dag.cregs.values():
... | """Build a ``DAGDependency`` object from a ``DAGCircuit``.
Args:
dag (DAGCircuit): the input dag.
create_preds_and_succs (bool): whether to construct lists of
predecessors and successors for every node.
Return:
DAGDependency: the DAG representing the input circuit as a ... | 54 | 303 | 298 | 601 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,480 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/dag_to_dagdependency_v2.py | 17,18 | 1,45 | _dag_to_dagdependency_v2 | 26,45 | 18,45 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | dagdependency = _DAGDependencyV2()
dagdependency.name = dag.name
dagdependency.metadata = dag.metadata
dagdependency.global_phase = dag.global_phase
dagdependency.calibrations = dag.calibrations
dagdependency.add_qubits(dag.qubits)
dagdependency.add_clbits(dag.clbits)
for register in d... | """Build a ``_DAGDependencyV2`` object from a ``DAGCircuit``.
Args:
dag (DAGCircuit): the input dag.
Return:
_DAGDependencyV2: the DAG representing the input circuit as a dag dependency.
"""
dagdependency = _DAGDependencyV2()
dagdependency.name = dag.name
dagdependency.meta... | 36 | 274 | 229 | 503 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,481 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/dagdependency_to_circuit.py | 17,18 | 1,43 | dagdependency_to_circuit | 26,43 | 18,43 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
name = dagdependency.name or None
circuit = QuantumCircuit(
dagdependency.qubits,
dagdependency.clbits,
*dagdependency.qregs.values(),
*dagdependency.cregs.values(),
name=name,
)
circuit.metadata = dagdependency.metadata
circuit.calibrations = dagdependency.... | """Build a ``QuantumCircuit`` object from a ``DAGDependency``.
Args:
dagdependency (DAGDependency): the input dag.
Return:
QuantumCircuit: the circuit representing the input dag dependency.
"""
name = dagdependency.name or None
circuit = QuantumCircuit(
dagdependency.q... | 29 | 257 | 164 | 421 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,482 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/converters/dagdependency_to_dag.py | 17,18 | 1,50 | dagdependency_to_dag | 26,50 | 18,50 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
dagcircuit = DAGCircuit()
dagcircuit.name = dagdependency.name
dagcircuit.metadata = dagdependency.metadata
dagcircuit.add_qubits(dagdependency.qubits)
dagcircuit.add_clbits(dagdependency.clbits)
for register in dagdependency.qregs.values():
dagcircuit.add_qreg(register)
for regi... | """Build a ``DAGCircuit`` object from a ``DAGDependency``.
Args:
dag dependency (DAGDependency): the input dag.
Return:
DAGCircuit: the DAG representing the input circuit.
"""
dagcircuit = DAGCircuit()
dagcircuit.name = dagdependency.name
dagcircuit.metadata = dagdependenc... | 50 | 258 | 275 | 533 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,484 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/dagcircuit/collect_blocks.py | 339,340 | 324,392 | collapse_to_operation | BlockCollapser | 343,392 | 340,392 | class BlockCollapser:
"""This class implements various strategies of consolidating blocks of nodes
in a DAG (direct acyclic graph). It works both with the
:class:`~qiskit.dagcircuit.DAGCircuit` and
:class:`~qiskit.dagcircuit.DAGDependency` DAG representations.
"""
def __init__(self, dag):
... | class BlockCollapser:
"""This class implements various strategies of consolidating blocks of nodes
in a DAG (direct acyclic graph). It works both with the
:class:`~qiskit.dagcircuit.DAGCircuit` and
:class:`~qiskit.dagcircuit.DAGDependency` DAG representations.
"""
def __init__(self, dag):
... | global_index_map = {wire: idx for idx, wire in enumerate(self.dag.qubits)}
global_index_map.update({wire: idx for idx, wire in enumerate(self.dag.clbits)})
for block in blocks:
# Find the sets of qubits/clbits used in this block (which might be much smaller
# than the se... | """For each block, constructs a quantum circuit containing instructions in the block,
then uses collapse_fn to collapse this circuit into a single operation.
"""
global_index_map = {wire: idx for idx, wire in enumerate(self.dag.qubits)}
global_index_map.update({wire: idx for idx,... | 237 | 206 | 715 | 921 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,486 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/dagcircuit/collect_blocks.py | 255,256 | 247,298 | find_leader | BlockSplitter | 257,266 | 256,266 | class BlockSplitter:
"""Splits a block of nodes into sub-blocks over disjoint qubits.
The implementation is based on the Disjoint Set Union data structure."""
def __init__(self):
self.leader = {} # qubit's group leader
self.group = {} # qubit's group
def find_leader(self, index):
FIL... | class BlockSplitter:
"""Splits a block of nodes into sub-blocks over disjoint qubits.
The implementation is based on the Disjoint Set Union data structure."""
def __init__(self):
self.leader = {} # qubit's group leader
self.group = {} # qubit's group
def find_leader(self, index):
... | if index not in self.leader:
self.leader[index] = index
self.group[index] = []
return index
if self.leader[index] == index:
return index
self.leader[index] = self.find_leader(self.leader[index])
return self.leader[index]
| """Find in DSU."""
if index not in self.leader:
self.leader[index] = index
self.group[index] = []
return index
if self.leader[index] == index:
return index
self.leader[index] = self.find_leader(self.leader[index])
return self.leader... | 24 | 413 | 97 | 510 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,490 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/dagcircuit/dagdepnode.py | 135,136 | 21,161 | copy | DAGDepNode | 141,161 | 136,161 | class DAGDepNode:
"""Object to represent the information at a node in the DAGDependency().
It is used as the return value from `*_nodes()` functions and can
be supplied to functions that take a node.
"""
__slots__ = [
"type",
"_op",
"name",
"_qargs",
"cargs"... | class DAGDepNode:
"""Object to represent the information at a node in the DAGDependency().
It is used as the return value from `*_nodes()` functions and can
be supplied to functions that take a node.
"""
__slots__ = [
"type",
"_op",
"name",
"_qargs",
"cargs"... |
dagdepnode = DAGDepNode()
dagdepnode.type = self.type
dagdepnode._op = self.op
dagdepnode.name = self.name
dagdepnode._qargs = self._qargs
dagdepnode.cargs = self.cargs
dagdepnode.node_id = self.node_id
dagdepnode.sort_key = self.sort_key
dagdepn... | """
Function to copy a DAGDepNode object.
Returns:
DAGDepNode: a copy of a DAGDepNode object.
"""
dagdepnode = DAGDepNode()
dagdepnode.type = self.type
dagdepnode._op = self.op
dagdepnode.name = self.name
dagdepnode._qargs = self._qar... | 50 | 1,153 | 271 | 1,424 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,492 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/dagcircuit/dagnode.py | 198,200 | 178,258 | semantic_eq | DAGNode | 215,258 | 200,258 | class DAGNode:
"""Parent class for DAGOpNode, DAGInNode, and DAGOutNode."""
__slots__ = ["_node_id"]
def __init__(self, nid=-1):
"""Create a node"""
self._node_id = nid
def __lt__(self, other):
return self._node_id < other._node_id
def __gt__(self, other):
return ... | class DAGNode:
"""Parent class for DAGOpNode, DAGInNode, and DAGOutNode."""
__slots__ = ["_node_id"]
def __init__(self, nid=-1):
"""Create a node"""
self._node_id = nid
def __lt__(self, other):
return self._node_id < other._node_id
def __gt__(self, other):
return ... | if not isinstance(node1, DAGOpNode) or not isinstance(node1, DAGOpNode):
return type(node1) is type(node2) and bit_indices1.get(node1.wire) == bit_indices2.get(
node2.wire
)
if isinstance(node1.op, ControlFlowOp) and isinstance(node2.op, ControlFlowOp):
... | """
Check if DAG nodes are considered equivalent, e.g., as a node_match for
:func:`rustworkx.is_isomorphic_node_match`.
Args:
node1 (DAGOpNode, DAGInNode, DAGOutNode): A node to compare.
node2 (DAGOpNode, DAGInNode, DAGOutNode): The other node to compare.
... | 196 | 386 | 715 | 1,101 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... |
30,493 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/dagcircuit/dagnode.py | 284,286 | 258,299 | name | DAGOpNode | 287,289 | 286,289 | class DAGOpNode(DAGNode):
"""Object to represent an Instruction at a node in the DAGCircuit."""
__slots__ = ["op", "qargs", "cargs", "sort_key"]
def __init__(
self, op: Operation, qargs: Iterable[Qubit] = (), cargs: Iterable[Clbit] = (), dag=None
):
"""Create an Instruction node"""
... | class DAGOpNode(DAGNode):
"""Object to represent an Instruction at a node in the DAGCircuit."""
__slots__ = ["op", "qargs", "cargs", "sort_key"]
def __init__(
self, op: Operation, qargs: Iterable[Qubit] = (), cargs: Iterable[Clbit] = (), dag=None
):
"""Create an Instruction node"""
... | return self.op.name
| """Returns the Instruction name corresponding to the op for this node"""
return self.op.name
| 2 | 446 | 11 | 457 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... |
30,494 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/passmanager/base_tasks.py | 202,208 | 156,231 | execute | BaseController | 208,231 | 208,231 | class BaseController(Task, ABC):
"""Base class of controller.
A controller is built with a collection of pass manager tasks,
and a subclass provides a custom logic to choose next task to run.
Note a controller can be nested into another controller,
and a controller itself doesn't provide any subrou... | class BaseController(Task, ABC):
"""Base class of controller.
A controller is built with a collection of pass manager tasks,
and a subclass provides a custom logic to choose next task to run.
Note a controller can be nested into another controller,
and a controller itself doesn't provide any subrou... | # Overriding this method is not safe.
# Pass subclass must keep current implementation.
# Especially, task execution may break when method signature is modified.
task_generator = self.iter_tasks(state)
try:
next_task = task_generator.send(None)
except StopIte... | # Overriding this method is not safe.
# Pass subclass must keep current implementation.
# Especially, task execution may break when method signature is modified.
task_generator = self.iter_tasks(state)
try:
next_task = task_generator.send(None)
except StopIte... | 83 | 453 | 229 | 682 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,495 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/passmanager/base_tasks.py | 72,78 | 57,156 | execute | GenericPass | 78,120 | 78,120 | class GenericPass(Task, ABC):
"""Base class of a single pass manager task.
A pass instance can read and write to the provided :class:`.PropertySet`,
and may modify the input pass manager IR.
"""
def __init__(self):
self.property_set = PropertySet()
self.requires: Iterable[Task] = [... | class GenericPass(Task, ABC):
"""Base class of a single pass manager task.
A pass instance can read and write to the provided :class:`.PropertySet`,
and may modify the input pass manager IR.
"""
def __init__(self):
self.property_set = PropertySet()
self.requires: Iterable[Task] = [... | # Overriding this method is not safe.
# Pass subclass must keep current implementation.
# Especially, task execution may break when method signature is modified.
self.property_set = state.property_set
if self.requires:
# pylint: disable=cyclic-import
from... | # Overriding this method is not safe.
# Pass subclass must keep current implementation.
# Especially, task execution may break when method signature is modified.
self.property_set = state.property_set
if self.requires:
# pylint: disable=cyclic-import
from... | 116 | 424 | 438 | 862 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,496 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/passmanager/flow_controllers.py | 113,114 | 90,117 | iter_tasks | ConditionalController | 114,117 | 114,117 | class ConditionalController(BaseController):
"""A flow controller runs the pipeline once if the condition is true, or does nothing if the
condition is false."""
def __init__(
self,
tasks: Task | Iterable[Task] = (),
condition: Callable[[PropertySet], bool] = None,
*,
... | class ConditionalController(BaseController):
"""A flow controller runs the pipeline once if the condition is true, or does nothing if the
condition is false."""
def __init__(
self,
tasks: Task | Iterable[Task] = (),
condition: Callable[[PropertySet], bool] = None,
*,
... | if self.condition(state.property_set):
for task in self.tasks:
state = yield task
| if self.condition(state.property_set):
for task in self.tasks:
state = yield task
| 10 | 233 | 32 | 265 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... |
30,497 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/passmanager/flow_controllers.py | 78,79 | 52,90 | iter_tasks | DoWhileController | 79,90 | 79,90 | class DoWhileController(BaseController):
"""Run the given tasks in a loop until the ``do_while`` condition on the property set becomes
``False``.
The given tasks will always run at least once, and on iteration of the loop, all the
tasks will be run (with the exception of a failure state being set)."""
... | class DoWhileController(BaseController):
"""Run the given tasks in a loop until the ``do_while`` condition on the property set becomes
``False``.
The given tasks will always run at least once, and on iteration of the loop, all the
tasks will be run (with the exception of a failure state being set)."""
... | max_iteration = self._options.get("max_iteration", 1000)
for _ in range(max_iteration):
for task in self.tasks:
state = yield task
if not self.do_while(state.property_set):
return
# Remove stored tasks from the completed task collection... | max_iteration = self._options.get("max_iteration", 1000)
for _ in range(max_iteration):
for task in self.tasks:
state = yield task
if not self.do_while(state.property_set):
return
# Remove stored tasks from the completed task collection... | 40 | 281 | 149 | 430 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... |
30,498 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/passmanager/flow_controllers.py | 47,48 | 27,52 | iter_tasks | FlowControllerLinear | 48,52 | 48,52 | class FlowControllerLinear(BaseController):
"""A standard flow controller that runs tasks one after the other."""
def __init__(
self,
tasks: Task | Iterable[Task] = (),
*,
options: dict[str, Any] | None = None,
):
super().__init__(options)
if not isinstance(... | class FlowControllerLinear(BaseController):
"""A standard flow controller that runs tasks one after the other."""
def __init__(
self,
tasks: Task | Iterable[Task] = (),
*,
options: dict[str, Any] | None = None,
):
super().__init__(options)
if not isinstance(... | for task in self.tasks:
state = yield task
| for task in self.tasks:
state = yield task
| 8 | 199 | 22 | 221 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019, 2023
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or de... |
30,503 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/backend_sampler.py | 156,159 | 33,214 | _postprocessing | BackendSampler | 159,174 | 159,174 | class BackendSampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""A :class:`~.BaseSampler` implementation that provides an interface for
leveraging the sampler interface from any backend.
This class provides a sampler interface from any backend and doesn't do
any measurement mitigation, it just comput... | class BackendSampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""A :class:`~.BaseSampler` implementation that provides an interface for
leveraging the sampler interface from any backend.
This class provides a sampler interface from any backend and doesn't do
any measurement mitigation, it just comput... | counts = _prepare_counts(result)
shots = sum(counts[0].values())
probabilities = []
metadata: list[dict[str, Any]] = [{} for _ in range(len(circuits))]
for count in counts:
prob_dist = {k: v / shots for k, v in count.items()}
probabilities.append(
... | counts = _prepare_counts(result)
shots = sum(counts[0].values())
probabilities = []
metadata: list[dict[str, Any]] = [{} for _ in range(len(circuits))]
for count in counts:
prob_dist = {k: v / shots for k, v in count.items()}
probabilities.append(
... | 50 | 1,640 | 173 | 1,813 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,505 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/backend_sampler_v2.py | 193,201 | 65,219 | _postprocess_pub | BackendSamplerV2 | 202,219 | 201,219 | class BackendSamplerV2(BaseSamplerV2):
"""Evaluates bitstrings for provided quantum circuits
The :class:`~.BackendSamplerV2` class is a generic implementation of the
:class:`~.BaseSamplerV2` interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the class :class:`~.Ba... | class BackendSamplerV2(BaseSamplerV2):
"""Evaluates bitstrings for provided quantum circuits
The :class:`~.BackendSamplerV2` class is a generic implementation of the
:class:`~.BaseSamplerV2` interface that is used to wrap a :class:`~.BackendV2`
(or :class:`~.BackendV1`) object in the class :class:`~.Ba... | arrays = {
item.creg_name: np.zeros(shape + (shots, item.num_bytes), dtype=np.uint8)
for item in meas_info
}
memory_array = _memory_array(result_memory, max_num_bytes)
for samples, index in zip(memory_array, np.ndindex(*shape)):
for item in meas_info:... | """Converts the memory data into an array of bit arrays with the shape of the pub."""
arrays = {
item.creg_name: np.zeros(shape + (shots, item.num_bytes), dtype=np.uint8)
for item in meas_info
}
memory_array = _memory_array(result_memory, max_num_bytes)
f... | 51 | 1,536 | 232 | 1,768 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,506 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_estimator.py | 120,127 | 41,190 | run | BaseEstimatorV1 | 163,179 | 127,179 | class BaseEstimatorV1(BasePrimitive, Generic[T]):
r"""Estimator V1 base class.
Base class for Estimator that estimates expectation values of quantum circuits and observables.
An estimator is initialized with an empty parameter set. The estimator is used to
create a :class:`~qiskit.providers.JobV1`, vi... | class BaseEstimatorV1(BasePrimitive, Generic[T]):
r"""Estimator V1 base class.
Base class for Estimator that estimates expectation values of quantum circuits and observables.
An estimator is initialized with an empty parameter set. The estimator is used to
create a :class:`~qiskit.providers.JobV1`, vi... | # Validation
circuits, observables, parameter_values = validation._validate_estimator_args(
circuits, observables, parameter_values
)
# Options
run_opts = copy(self.options)
run_opts.update_options(**run_options)
return self._run(
circuit... | """Run the job of the estimation of expectation value(s).
``circuits``, ``observables``, and ``parameter_values`` should have the same
length. The i-th element of the result is the expectation of observable
.. code-block:: python
obs = observables[i]
for the state... | 24 | 1,460 | 123 | 1,583 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... |
30,507 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_estimator.py | 204,206 | 193,226 | _make_data_bin | BaseEstimatorV2 | 206,210 | 206,210 | class BaseEstimatorV2(ABC):
r"""Estimator V2 base class.
An estimator estimates expectation values for provided quantum circuit and
observable combinations.
An Estimator implementation must treat the :meth:`.run` method ``precision=None``
kwarg as using a default ``precision`` value. The default ... | class BaseEstimatorV2(ABC):
r"""Estimator V2 base class.
An estimator estimates expectation values for provided quantum circuit and
observable combinations.
An Estimator implementation must treat the :meth:`.run` method ``precision=None``
kwarg as using a default ``precision`` value. The default ... | # this method is present for backwards compat. new primitive implementatinos
# should avoid it.
return DataBin
| # this method is present for backwards compat. new primitive implementatinos
# should avoid it.
return DataBin
| 17 | 332 | 34 | 366 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or d... |
30,508 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_primitive.py | 30,32 | 22,46 | options | BasePrimitive | 37,39 | 32,39 | class BasePrimitive(ABC):
"""Primitive abstract base class."""
def __init__(self, options: dict | None = None):
self._run_options = Options()
if options is not None:
self._run_options.update_options(**options)
@property
def options(self) -> Options:
FILL_FUNC_BODY def se... | class BasePrimitive(ABC):
"""Primitive abstract base class."""
def __init__(self, options: dict | None = None):
self._run_options = Options()
if options is not None:
self._run_options.update_options(**options)
@property
def options(self) -> Options:
"""Return option... | return self._run_options
| """Return options values for the estimator.
Returns:
options
"""
return self._run_options
| 2 | 172 | 11 | 183 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,509 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_primitive_job.py | 68,70 | 26,79 | in_final_state | BasePrimitiveJob | 71,75 | 70,75 | class BasePrimitiveJob(ABC, Generic[ResultT, StatusT]):
"""Primitive job abstract base class."""
def __init__(self, job_id: str, **kwargs) -> None:
"""Initializes the primitive job.
Args:
job_id: A unique id in the context of the primitive used to run the job.
kwargs: A... | class BasePrimitiveJob(ABC, Generic[ResultT, StatusT]):
"""Primitive job abstract base class."""
def __init__(self, job_id: str, **kwargs) -> None:
"""Initializes the primitive job.
Args:
job_id: A unique id in the context of the primitive used to run the job.
kwargs: A... | raise NotImplementedError(
"Subclass of BasePrimitiveJob must implement `is_final_state` method."
)
| """Return whether the job is in a final job state such as ``DONE`` or ``ERROR``."""
raise NotImplementedError(
"Subclass of BasePrimitiveJob must implement `is_final_state` method."
)
| 10 | 526 | 38 | 564 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,510 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_result.py | 62,64 | 28,66 | _field_values | _BasePrimitiveResult | 65,66 | 64,66 | class _BasePrimitiveResult(ABC):
"""
Base class for deprecated Primitive result methods.
"""
def __post_init__(self) -> None:
"""
Verify that all fields in any inheriting result dataclass are consistent, after
instantiation, with the number of experiments being represented.
... | class _BasePrimitiveResult(ABC):
"""
Base class for deprecated Primitive result methods.
"""
def __post_init__(self) -> None:
"""
Verify that all fields in any inheriting result dataclass are consistent, after
instantiation, with the number of experiments being represented.
... | return tuple(getattr(self, name) for name in self._field_names)
| """Tuple of field values in any inheriting result dataclass."""
return tuple(getattr(self, name) for name in self._field_names)
| 7 | 455 | 22 | 477 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,511 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/base/base_sampler.py | 143,150 | 35,153 | _run | BaseSamplerV1 | 150,153 | 150,153 | class BaseSamplerV1(BasePrimitive, Generic[T]):
r"""Sampler V1 base class
Base class of Sampler that calculates quasi-probabilities of bitstrings from quantum circuits.
A sampler is initialized with an empty parameter set. The sampler is used to
create a :class:`~qiskit.providers.JobV1`, via the :meth... | class BaseSamplerV1(BasePrimitive, Generic[T]):
r"""Sampler V1 base class
Base class of Sampler that calculates quasi-probabilities of bitstrings from quantum circuits.
A sampler is initialized with an empty parameter set. The sampler is used to
create a :class:`~qiskit.providers.JobV1`, via the :meth... | raise NotImplementedError("The subclass of BaseSampler must implement `_run` method.")
| raise NotImplementedError("The subclass of BaseSampler must implement `_run` method.")
| 9 | 1,173 | 29 | 1,202 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,515 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/data_bin.py | 25,26 | 1,166 | _value_repr | 27,32 | 26,32 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | if isinstance(value, np.ndarray):
return f"np.ndarray(<shape={value.shape}, dtype={value.dtype}>)"
return repr(value)
| """Helper function for :meth:`DataBin.__repr__`."""
if isinstance(value, np.ndarray):
return f"np.ndarray(<shape={value.shape}, dtype={value.dtype}>)"
return repr(value)
| 8 | 1,547 | 57 | 1,604 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,516 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/data_bin.py | 141,143 | 32,147 | _SHAPE | DataBin | 143,147 | 143,147 | class DataBin(ShapedMixin):
"""Namespace for storing data.
.. code-block:: python
data = DataBin(
alpha=BitArray.from_bitstrings(["0010"]),
beta=np.array([1.2])
)
print("alpha data:", data.alpha)
print("beta data:", data.beta)
"""
__slots__ = ... | class DataBin(ShapedMixin):
"""Namespace for storing data.
.. code-block:: python
data = DataBin(
alpha=BitArray.from_bitstrings(["0010"]),
beta=np.array([1.2])
)
print("alpha data:", data.alpha)
print("beta data:", data.beta)
"""
__slots__ = ... | return self.shape
# pylint: disable=unused-argument
| return self.shape
# pylint: disable=unused-argument
| 5 | 1,070 | 24 | 1,094 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,517 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/estimator_pub.py | 170,171 | 36,202 | validate | EstimatorPub | 172,202 | 171,202 | class EstimatorPub(ShapedMixin):
"""Primitive Unified Bloc for any Estimator primitive.
An estimator pub is essentially a tuple ``(circuit, observables, parameter_values, precision)``.
If precision is provided this should be used for the target precision of an
estimator, if ``precision=None`` the esti... | class EstimatorPub(ShapedMixin):
"""Primitive Unified Bloc for any Estimator primitive.
An estimator pub is essentially a tuple ``(circuit, observables, parameter_values, precision)``.
If precision is provided this should be used for the target precision of an
estimator, if ``precision=None`` the esti... | if not isinstance(self.circuit, QuantumCircuit):
raise TypeError("circuit must be QuantumCircuit.")
self.observables.validate()
self.parameter_values.validate()
if self.precision is not None:
if not isinstance(self.precision, Real):
raise TypeErr... | """Validate the pub."""
if not isinstance(self.circuit, QuantumCircuit):
raise TypeError("circuit must be QuantumCircuit.")
self.observables.validate()
self.parameter_values.validate()
if self.precision is not None:
if not isinstance(self.precision, Real... | 113 | 1,321 | 376 | 1,697 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,520 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/primitive_result.py | 38,40 | 25,54 | metadata | PrimitiveResult | 41,43 | 40,43 | class PrimitiveResult(Generic[T]):
"""A container for multiple pub results and global metadata."""
def __init__(self, pub_results: Iterable[T], metadata: dict[str, Any] | None = None):
"""
Args:
pub_results: Pub results.
metadata: Metadata that is common to all pub resul... | class PrimitiveResult(Generic[T]):
"""A container for multiple pub results and global metadata."""
def __init__(self, pub_results: Iterable[T], metadata: dict[str, Any] | None = None):
"""
Args:
pub_results: Pub results.
metadata: Metadata that is common to all pub resul... | return self._metadata
| """The metadata of this primitive result."""
return self._metadata
| 2 | 290 | 9 | 299 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,521 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/pub_result.py | 48,50 | 24,52 | metadata | PubResult | 51,52 | 50,52 | class PubResult:
"""Result of Primitive Unified Bloc."""
__slots__ = ("_data", "_metadata")
def __init__(self, data: DataBin, metadata: dict[str, Any] | None = None):
"""Initialize a pub result.
Args:
data: Result data.
metadata: Metadata specific to this pub. Keys... | class PubResult:
"""Result of Primitive Unified Bloc."""
__slots__ = ("_data", "_metadata")
def __init__(self, data: DataBin, metadata: dict[str, Any] | None = None):
"""Initialize a pub result.
Args:
data: Result data.
metadata: Metadata specific to this pub. Keys... | return self._metadata
| """Metadata for the pub."""
return self._metadata
| 2 | 240 | 7 | 247 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,522 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/sampler_pub.py | 143,144 | 34,172 | validate | SamplerPub | 145,172 | 144,172 | class SamplerPub(ShapedMixin):
"""Pub (Primitive Unified Bloc) for a Sampler.
Pub is composed of tuple (circuit, parameter_values, shots).
If shots are provided this number of shots will be run with the sampler,
if ``shots=None`` the number of run shots is determined by the sampler.
"""
def _... | class SamplerPub(ShapedMixin):
"""Pub (Primitive Unified Bloc) for a Sampler.
Pub is composed of tuple (circuit, parameter_values, shots).
If shots are provided this number of shots will be run with the sampler,
if ``shots=None`` the number of run shots is determined by the sampler.
"""
def _... | if not isinstance(self.circuit, QuantumCircuit):
raise TypeError("circuit must be QuantumCircuit.")
self.parameter_values.validate()
if self.shots is not None:
if not isinstance(self.shots, Integral) or isinstance(self.shots, bool):
raise TypeError("shot... | """Validate the pub."""
if not isinstance(self.circuit, QuantumCircuit):
raise TypeError("circuit must be QuantumCircuit.")
self.parameter_values.validate()
if self.shots is not None:
if not isinstance(self.shots, Integral) or isinstance(self.shots, bool):
... | 109 | 1,068 | 320 | 1,388 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,523 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/sampler_pub_result.py | 30,31 | 27,75 | join_data | SamplerPubResult | 51,75 | 31,75 | class SamplerPubResult(PubResult):
"""Result of Sampler Pub."""
def join_data(self, names: Iterable[str] | None = None) -> BitArray | np.ndarray:
FILL_FUNC_BODY | class SamplerPubResult(PubResult):
"""Result of Sampler Pub."""
def join_data(self, names: Iterable[str] | None = None) -> BitArray | np.ndarray:
"""Join data from many registers into one data container.
Data is joined along the bits axis. For example, for :class:`~.BitArray` data, this corres... | if names is None:
names = list(self.data)
if not names:
raise ValueError("No entry exists in the data bin.")
else:
names = list(names)
if not names:
raise ValueError("An empty name list is given.")
for name in na... | """Join data from many registers into one data container.
Data is joined along the bits axis. For example, for :class:`~.BitArray` data, this corresponds
to bitstring concatenation.
Args:
names: Which registers to join. Their order is maintained, for example, given
... | 104 | 259 | 300 | 559 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,524 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/shape.py | 91,92 | 1,130 | _flatten_to_ints | 104,116 | 92,116 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | for item in arg:
try:
if isinstance(item, Iterable):
yield from _flatten_to_ints(item)
elif int(item) == item:
yield int(item)
else:
raise ValueError(f"Expected {item} to be iterable or an integer.")
except (TypeErro... | """
Yield one integer at a time.
Args:
arg: Integers or iterables of integers, possibly nested, to be yielded.
Yields:
The provided integers in depth-first recursive order.
Raises:
ValueError: If an input is not an iterable or an integer.
"""
for item in arg:
... | 43 | 1,037 | 128 | 1,165 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,525 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/shape.py | 37,39 | 28,53 | shape | Shaped | 40,42 | 39,42 | @runtime_checkable
class Shaped(Protocol):
"""Protocol that defines what it means to be a shaped object.
Note that static type checkers will classify ``numpy.ndarray`` as being :class:`Shaped`.
Moreover, since this protocol is runtime-checkable, we will even have
``isinstance(<numpy.ndarray instance>, ... | @runtime_checkable
class Shaped(Protocol):
"""Protocol that defines what it means to be a shaped object.
Note that static type checkers will classify ``numpy.ndarray`` as being :class:`Shaped`.
Moreover, since this protocol is runtime-checkable, we will even have
``isinstance(<numpy.ndarray instance>, ... | raise NotImplementedError("A `Shaped` protocol must implement the `shape` property")
| """The array shape of this object."""
raise NotImplementedError("A `Shaped` protocol must implement the `shape` property")
| 9 | 262 | 26 | 288 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,526 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/containers/shape.py | 69,71 | 53,74 | size | ShapedMixin | 71,74 | 71,74 | class ShapedMixin(Shaped):
"""Mixin class to create :class:`~Shaped` types by only providing :attr:`_shape` attribute."""
_shape: tuple[int, ...]
def __repr__(self):
return f"{type(self).__name__}(<{self.shape}>)"
@property
def shape(self):
return self._shape
@property
de... | class ShapedMixin(Shaped):
"""Mixin class to create :class:`~Shaped` types by only providing :attr:`_shape` attribute."""
_shape: tuple[int, ...]
def __repr__(self):
return f"{type(self).__name__}(<{self.shape}>)"
@property
def shape(self):
return self._shape
@property
de... | return int(np.prod(self._shape, dtype=int))
| return int(np.prod(self._shape, dtype=int))
| 3 | 145 | 23 | 168 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,527 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/estimator.py | 126,133 | 38,159 | _run | Estimator | 133,159 | 133,159 | class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
"""
Reference implementation of :class:`BaseEstimator`.
:Run Options:
- **shots** (None or int) --
The number of shots. If None, it calculates the exact expectation
values. Otherwise, it samples from normal distribu... | class Estimator(BaseEstimator[PrimitiveJob[EstimatorResult]]):
"""
Reference implementation of :class:`BaseEstimator`.
:Run Options:
- **shots** (None or int) --
The number of shots. If None, it calculates the exact expectation
values. Otherwise, it samples from normal distribu... | circuit_indices = []
for circuit in circuits:
key = _circuit_key(circuit)
index = self._circuit_ids.get(key)
if index is not None:
circuit_indices.append(index)
else:
circuit_indices.append(len(self._circuits))
... | circuit_indices = []
for circuit in circuits:
key = _circuit_key(circuit)
index = self._circuit_ids.get(key)
if index is not None:
circuit_indices.append(index)
else:
circuit_indices.append(len(self._circuits))
... | 63 | 1,052 | 323 | 1,375 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,528 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/primitive_job.py | 80,81 | 25,82 | in_final_state | PrimitiveJob | 81,82 | 81,82 | class PrimitiveJob(BasePrimitiveJob[ResultT, JobStatus]):
"""
Primitive job class for the reference implementations of Primitives.
"""
def __init__(self, function, *args, **kwargs):
"""
Args:
function: A callable function to execute the job.
"""
super().__ini... | class PrimitiveJob(BasePrimitiveJob[ResultT, JobStatus]):
"""
Primitive job class for the reference implementations of Primitives.
"""
def __init__(self, function, *args, **kwargs):
"""
Args:
function: A callable function to execute the job.
"""
super().__ini... | return self.status() in JOB_FINAL_STATES
| return self.status() in JOB_FINAL_STATES
| 4 | 517 | 18 | 535 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,529 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/sampler.py | 69,75 | 38,156 | _call | Sampler | 75,119 | 75,119 | class Sampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""
Sampler class.
:class:`~Sampler` is a reference implementation of :class:`~BaseSampler`.
:Run Options:
- **shots** (None or int) --
The number of shots. If None, it calculates the probabilities.
Otherwise, it sam... | class Sampler(BaseSampler[PrimitiveJob[SamplerResult]]):
"""
Sampler class.
:class:`~Sampler` is a reference implementation of :class:`~BaseSampler`.
:Run Options:
- **shots** (None or int) --
The number of shots. If None, it calculates the probabilities.
Otherwise, it sam... | shots = run_options.pop("shots", None)
seed = run_options.pop("seed", None)
if seed is None:
rng = np.random.default_rng()
elif isinstance(seed, np.random.Generator):
rng = seed
else:
rng = np.random.default_rng(seed)
# Initialize meta... | shots = run_options.pop("shots", None)
seed = run_options.pop("seed", None)
if seed is None:
rng = np.random.default_rng()
elif isinstance(seed, np.random.Generator):
rng = seed
else:
rng = np.random.default_rng(seed)
# Initialize meta... | 146 | 778 | 553 | 1,331 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,530 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/statevector_estimator.py | 141,142 | 31,166 | _run_pub | StatevectorEstimator | 142,166 | 142,166 | class StatevectorEstimator(BaseEstimatorV2):
"""
Simple implementation of :class:`BaseEstimatorV2` with full state vector simulation.
This class is implemented via :class:`~.Statevector` which turns provided circuits into
pure state vectors. These states are subsequently acted on by :class:~.SparsePaul... | class StatevectorEstimator(BaseEstimatorV2):
"""
Simple implementation of :class:`BaseEstimatorV2` with full state vector simulation.
This class is implemented via :class:`~.Statevector` which turns provided circuits into
pure state vectors. These states are subsequently acted on by :class:~.SparsePaul... | rng = np.random.default_rng(self._seed)
circuit = pub.circuit
observables = pub.observables
parameter_values = pub.parameter_values
precision = pub.precision
bound_circuits = parameter_values.bind_all(circuit)
bc_circuits, bc_obs = np.broadcast_arrays(bound_circui... | rng = np.random.default_rng(self._seed)
circuit = pub.circuit
observables = pub.observables
parameter_values = pub.parameter_values
precision = pub.precision
bound_circuits = parameter_values.bind_all(circuit)
bc_circuits, bc_obs = np.broadcast_arrays(bound_circui... | 95 | 1,268 | 428 | 1,696 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,532 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/primitives/statevector_sampler.py | 172,173 | 52,203 | _run | StatevectorSampler | 173,176 | 173,176 | class StatevectorSampler(BaseSamplerV2):
"""
Simple implementation of :class:`BaseSamplerV2` using full state vector simulation.
This class is implemented via :class:`~.Statevector` which turns provided circuits into
pure state vectors, and is therefore incompatible with mid-circuit measurements (altho... | class StatevectorSampler(BaseSamplerV2):
"""
Simple implementation of :class:`BaseSamplerV2` using full state vector simulation.
This class is implemented via :class:`~.Statevector` which turns provided circuits into
pure state vectors, and is therefore incompatible with mid-circuit measurements (altho... | results = [self._run_pub(pub) for pub in pubs]
return PrimitiveResult(results)
| results = [self._run_pub(pub) for pub in pubs]
return PrimitiveResult(results)
| 9 | 1,737 | 32 | 1,769 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2023, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,533 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/backend.py | 122,123 | 40,245 | set_options | BackendV1 | 136,141 | 123,141 | class BackendV1(Backend, ABC):
"""Abstract class for Backends
This abstract class is to be used for Backend objects.
There are several classes of information contained in a Backend.
The first are the attributes of the class itself. These should be used to
defined the immutable characteristics of th... | class BackendV1(Backend, ABC):
"""Abstract class for Backends
This abstract class is to be used for Backend objects.
There are several classes of information contained in a Backend.
The first are the attributes of the class itself. These should be used to
defined the immutable characteristics of th... | for field in fields:
if not hasattr(self._options, field):
raise AttributeError("Options field %s is not valid for this backend" % field)
self._options.update_options(**fields)
| """Set the options fields for the backend
This method is used to update the options of a backend. If
you need to change any of the options prior to running just
pass in the kwarg with the new value for the options.
Args:
fields: The fields to update the options
... | 21 | 1,839 | 60 | 1,899 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,535 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/basic_provider/basic_provider.py | 81,82 | 38,102 | _get_backend_instance | BasicProvider | 92,100 | 82,100 | class BasicProvider(ProviderV1):
"""Provider for test simulators."""
def __init__(self) -> None:
super().__init__()
# Populate the list of test backends (simulators)
self._backends = self._verify_backends()
def get_backend(self, name: str | None = None, **kwargs) -> Backend:
... | class BasicProvider(ProviderV1):
"""Provider for test simulators."""
def __init__(self) -> None:
super().__init__()
# Populate the list of test backends (simulators)
self._backends = self._verify_backends()
def get_backend(self, name: str | None = None, **kwargs) -> Backend:
... | # Verify that the backend can be instantiated.
try:
backend_instance = backend_cls(provider=self)
except Exception as err:
raise QiskitError(f"Backend {backend_cls} could not be instantiated: {err}") from err
return backend_instance
| """
Return an instance of a backend from its class.
Args:
backend_cls (class): backend class.
Returns:
Backend: a backend instance.
Raises:
QiskitError: if the backend could not be instantiated.
"""
# Verify that the backend ca... | 28 | 568 | 84 | 652 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,536 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/basic_provider/basic_provider_job.py | 39,40 | 22,66 | result | BasicProviderJob | 45,55 | 40,55 | class BasicProviderJob(JobV1):
"""BasicProviderJob class."""
_async = False
def __init__(self, backend, job_id, result):
super().__init__(backend, job_id)
self._result = result
def submit(self):
"""Submit the job to the backend for execution.
Raises:
JobEr... | class BasicProviderJob(JobV1):
"""BasicProviderJob class."""
_async = False
def __init__(self, backend, job_id, result):
super().__init__(backend, job_id)
self._result = result
def submit(self):
"""Submit the job to the backend for execution.
Raises:
JobEr... | if timeout is not None:
warnings.warn(
"The timeout kwarg doesn't have any meaning with "
"BasicProvider because execution is synchronous and the "
"result already exists when run() returns.",
UserWarning,
)
return ... | """Get job result .
Returns:
qiskit.result.Result: Result object
"""
if timeout is not None:
warnings.warn(
"The timeout kwarg doesn't have any meaning with "
"BasicProvider because execution is synchronous and the "
... | 33 | 245 | 80 | 325 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,539 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/fake_provider/fake_backend.py | 69,70 | 39,159 | properties | FakeBackend | 71,121 | 70,121 | class FakeBackend(BackendV1):
"""This is a dummy backend just for testing purposes."""
def __init__(self, configuration, time_alive=10):
"""FakeBackend initializer.
Args:
configuration (BackendConfiguration): backend configuration
time_alive (int): time to wait before r... | class FakeBackend(BackendV1):
"""This is a dummy backend just for testing purposes."""
def __init__(self, configuration, time_alive=10):
"""FakeBackend initializer.
Args:
configuration (BackendConfiguration): backend configuration
time_alive (int): time to wait before r... | coupling_map = self.configuration().coupling_map
if coupling_map is None:
return None
unique_qubits = list(set().union(*coupling_map))
properties = {
"backend_name": self.name(),
"backend_version": self.configuration().backend_version,
"la... | """Return backend properties"""
coupling_map = self.configuration().coupling_map
if coupling_map is None:
return None
unique_qubits = list(set().union(*coupling_map))
properties = {
"backend_name": self.name(),
"backend_version": self.configur... | 121 | 730 | 628 | 1,358 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,542 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/fake_provider/fake_pulse_backend.py | 42,43 | 24,44 | _get_config_from_dict | FakePulseBackend | 43,44 | 43,44 | class FakePulseBackend(FakeQasmBackend):
"""A fake pulse backend."""
defs_filename = None
def defaults(self):
"""Returns a snapshot of device defaults"""
if not self._defaults:
self._set_defaults_from_json()
return self._defaults
def _set_defaults_from_json(self):
... | class FakePulseBackend(FakeQasmBackend):
"""A fake pulse backend."""
defs_filename = None
def defaults(self):
"""Returns a snapshot of device defaults"""
if not self._defaults:
self._set_defaults_from_json()
return self._defaults
def _set_defaults_from_json(self):
... | return PulseBackendConfiguration.from_dict(conf)
| return PulseBackendConfiguration.from_dict(conf)
| 2 | 193 | 16 | 209 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,543 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/fake_provider/fake_qasm_backend.py | 59,60 | 30,73 | _set_props_from_json | FakeQasmBackend | 60,66 | 60,66 | class FakeQasmBackend(FakeBackend):
"""A fake OpenQASM backend."""
dirname = None
conf_filename = None
props_filename = None
backend_name = None
def __init__(self):
configuration = self._get_conf_from_json()
self._defaults = None
self._properties = None
super().... | class FakeQasmBackend(FakeBackend):
"""A fake OpenQASM backend."""
dirname = None
conf_filename = None
props_filename = None
backend_name = None
def __init__(self):
configuration = self._get_conf_from_json()
self._defaults = None
self._properties = None
super().... | if not self.props_filename:
raise QiskitError("No properties file has been defined")
props = self._load_json(self.props_filename)
decode_backend_properties(props)
self._properties = BackendProperties.from_dict(props)
| if not self.props_filename:
raise QiskitError("No properties file has been defined")
props = self._load_json(self.props_filename)
decode_backend_properties(props)
self._properties = BackendProperties.from_dict(props)
| 17 | 358 | 76 | 434 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,545 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/fake_provider/utils/backend_converter.py | 30,31 | 1,151 | convert_to_target | 34,135 | 31,135 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | name_mapping = {
"id": IGate(),
"sx": SXGate(),
"x": XGate(),
"cx": CXGate(),
"rz": RZGate(Parameter("λ")),
"reset": Reset(),
}
custom_gates = {}
qubit_props = None
if props_dict:
qubit_props = qubit_props_from_props(props_dict)
target = Ta... | """Uses configuration, properties and pulse defaults dicts
to construct and return Target class.
"""
name_mapping = {
"id": IGate(),
"sx": SXGate(),
"x": XGate(),
"cx": CXGate(),
"rz": RZGate(Parameter("λ")),
"reset": Reset(),
}
custom_gates = {}
... | 365 | 651 | 1,359 | 2,010 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,546 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/fake_provider/utils/json_decoder.py | 54,55 | 1,110 | decode_backend_configuration | 61,69 | 55,69 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | config["online_date"] = dateutil.parser.isoparse(config["online_date"])
if "u_channel_lo" in config:
for u_channle_list in config["u_channel_lo"]:
for u_channle_lo in u_channle_list:
u_channle_lo["scale"] = _to_complex(u_channle_lo["scale"])
| """Decode backend configuration.
Args:
config: A ``QasmBackendConfiguration`` or ``PulseBackendConfiguration``
in dictionary format.
"""
config["online_date"] = dateutil.parser.isoparse(config["online_date"])
if "u_channel_lo" in config:
for u_channle_list in config["u_... | 18 | 1,014 | 117 | 1,131 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | |
30,547 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/job.py | 68,69 | 42,148 | job_id | JobV1 | 70,72 | 69,72 | class JobV1(Job, ABC):
"""Class to handle jobs
This first version of the Backend abstract class is written to be mostly
backwards compatible with the legacy providers interface. This was done to ease
the transition for users and provider maintainers to the new versioned providers. Expect,
future ve... | class JobV1(Job, ABC):
"""Class to handle jobs
This first version of the Backend abstract class is written to be mostly
backwards compatible with the legacy providers interface. This was done to ease
the transition for users and provider maintainers to the new versioned providers. Expect,
future ve... | return self._job_id
| """Return a unique id identifying the job."""
return self._job_id
| 2 | 977 | 11 | 988 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,552 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/backendconfiguration.py | 100,101 | 31,136 | to_dict | GateConfig | 106,121 | 101,121 | class GateConfig:
"""Class representing a Gate Configuration
Attributes:
name: the gate name as it will be referred to in OpenQASM.
parameters: variable names for the gate parameters (if any).
qasm_def: definition of this gate in terms of OpenQASM 2 primitives U
and CX... | class GateConfig:
"""Class representing a Gate Configuration
Attributes:
name: the gate name as it will be referred to in OpenQASM.
parameters: variable names for the gate parameters (if any).
qasm_def: definition of this gate in terms of OpenQASM 2 primitives U
and CX... | out_dict = {
"name": self.name,
"parameters": self.parameters,
"qasm_def": self.qasm_def,
}
if hasattr(self, "coupling_map"):
out_dict["coupling_map"] = self.coupling_map
if hasattr(self, "latency_map"):
out_dict["latency_map"] ... | """Return a dictionary format representation of the GateConfig.
Returns:
dict: The dictionary form of the GateConfig.
"""
out_dict = {
"name": self.name,
"parameters": self.parameters,
"qasm_def": self.qasm_def,
}
if hasatt... | 36 | 843 | 182 | 1,025 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,555 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/backendconfiguration.py | 173,174 | 136,195 | to_dict | UchannelLO | 179,185 | 174,185 | class UchannelLO:
"""Class representing a U Channel LO
Attributes:
q: Qubit that scale corresponds too.
scale: Scale factor for qubit frequency.
"""
def __init__(self, q, scale):
"""Initialize a UchannelLOSchema object
Args:
q (int): Qubit that scale corres... | class UchannelLO:
"""Class representing a U Channel LO
Attributes:
q: Qubit that scale corresponds too.
scale: Scale factor for qubit frequency.
"""
def __init__(self, q, scale):
"""Initialize a UchannelLOSchema object
Args:
q (int): Qubit that scale corres... | out_dict = {
"q": self.q,
"scale": self.scale,
}
return out_dict
| """Return a dictionary format representation of the UChannelLO.
Returns:
dict: The dictionary form of the UChannelLO.
"""
out_dict = {
"q": self.q,
"scale": self.scale,
}
return out_dict
| 10 | 409 | 41 | 450 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,557 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/backendproperties.py | 141,142 | 88,162 | to_dict | GateProperties | 147,154 | 142,154 | class GateProperties:
"""Class representing a gate's properties
Attributes:
qubits: qubits.
gate: gate.
parameters: parameters.
"""
_data = {}
def __init__(self, qubits, gate, parameters, **kwargs):
"""Initialize a new :class:`GateProperties` object
Args:
... | class GateProperties:
"""Class representing a gate's properties
Attributes:
qubits: qubits.
gate: gate.
parameters: parameters.
"""
_data = {}
def __init__(self, qubits, gate, parameters, **kwargs):
"""Initialize a new :class:`GateProperties` object
Args:
... | out_dict = {}
out_dict["qubits"] = self.qubits
out_dict["gate"] = self.gate
out_dict["parameters"] = [x.to_dict() for x in self.parameters]
out_dict.update(self._data)
return out_dict
| """Return a dictionary format representation of the BackendStatus.
Returns:
dict: The dictionary form of the Gate.
"""
out_dict = {}
out_dict["qubits"] = self.qubits
out_dict["gate"] = self.gate
out_dict["parameters"] = [x.to_dict() for x in self.para... | 19 | 524 | 82 | 606 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,558 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/backendproperties.py | 64,65 | 26,88 | to_dict | Nduv | 70,78 | 65,78 | class Nduv:
"""Class representing name-date-unit-value
Attributes:
date: date.
name: name.
unit: unit.
value: value.
"""
def __init__(self, date, name, unit, value):
"""Initialize a new name-date-unit-value object
Args:
date (datetime.dateti... | class Nduv:
"""Class representing name-date-unit-value
Attributes:
date: date.
name: name.
unit: unit.
value: value.
"""
def __init__(self, date, name, unit, value):
"""Initialize a new name-date-unit-value object
Args:
date (datetime.dateti... | out_dict = {
"date": self.date,
"name": self.name,
"unit": self.unit,
"value": self.value,
}
return out_dict
| """Return a dictionary format representation of the object.
Returns:
dict: The dictionary form of the Nduv.
"""
out_dict = {
"date": self.date,
"name": self.name,
"unit": self.unit,
"value": self.value,
}
return... | 14 | 412 | 61 | 473 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,559 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/backendstatus.py | 78,79 | 19,95 | _repr_html_ | BackendStatus | 85,95 | 79,95 | class BackendStatus:
"""Class representing Backend Status."""
def __init__(
self,
backend_name: str,
backend_version: str,
operational: bool,
pending_jobs: int,
status_msg: str,
):
"""Initialize a BackendStatus object
Args:
backen... | class BackendStatus:
"""Class representing Backend Status."""
def __init__(
self,
backend_name: str,
backend_version: str,
operational: bool,
pending_jobs: int,
status_msg: str,
):
"""Initialize a BackendStatus object
Args:
backen... | rpr = self.__repr__()
html_code = (
f"<pre>{html.escape(rpr)}</pre>"
f"<b>name</b>: {self.backend_name}<br/>"
f"<b>version</b>: {self.backend_version},"
f" <b>pending jobs</b>: {self.pending_jobs}<br/>"
f"<b>status</b>: {self.status_msg}<br/>"
... | """Return html representation of the object
Returns:
Representation used in Jupyter notebook and other IDE's that call the method
"""
rpr = self.__repr__()
html_code = (
f"<pre>{html.escape(rpr)}</pre>"
f"<b>name</b>: {self.backend_name}<br/>... | 20 | 529 | 158 | 687 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... |
30,560 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/jobstatus.py | 48,49 | 16,67 | to_dict | JobStatus | 54,62 | 49,62 | class JobStatus:
"""Model for JobStatus.
Attributes:
job_id (str): backend job_id.
status (str): status of the job.
status_msg (str): status message.
"""
_data = {}
def __init__(self, job_id, status, status_msg, **kwargs):
self._data = {}
self.job_id = job_... | class JobStatus:
"""Model for JobStatus.
Attributes:
job_id (str): backend job_id.
status (str): status of the job.
status_msg (str): status message.
"""
_data = {}
def __init__(self, job_id, status, status_msg, **kwargs):
self._data = {}
self.job_id = job_... | out_dict = {
"job_id": self.job_id,
"status": self.status,
"status_msg": self.status_msg,
}
out_dict.update(self._data)
return out_dict
| """Return a dictionary format representation of the JobStatus.
Returns:
dict: The dictionary form of the JobStatus.
"""
out_dict = {
"job_id": self.job_id,
"status": self.status,
"status_msg": self.status_msg,
}
out_dict.up... | 13 | 343 | 72 | 415 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2018.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,561 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/pulsedefaults.py | 126,127 | 94,163 | to_dict | Command | 132,140 | 127,140 | class Command:
"""Class representing a Command.
Attributes:
name: Pulse command name.
"""
_data = {}
def __init__(self, name: str, qubits=None, sequence=None, **kwargs):
"""Initialize a Command object
Args:
name (str): The name of the command
qubit... | class Command:
"""Class representing a Command.
Attributes:
name: Pulse command name.
"""
_data = {}
def __init__(self, name: str, qubits=None, sequence=None, **kwargs):
"""Initialize a Command object
Args:
name (str): The name of the command
qubit... | out_dict = {"name": self.name}
if hasattr(self, "qubits"):
out_dict["qubits"] = self.qubits
if hasattr(self, "sequence"):
out_dict["sequence"] = [x.to_dict() for x in self.sequence]
out_dict.update(self._data)
return out_dict
| """Return a dictionary format representation of the Command.
Returns:
dict: The dictionary form of the Command.
"""
out_dict = {"name": self.name}
if hasattr(self, "qubits"):
out_dict["qubits"] = self.qubits
if hasattr(self, "sequence"):
... | 23 | 491 | 102 | 593 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
30,562 | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit | /home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/pulsedefaults.py | 79,81 | 58,94 | from_dict | Discriminator | 91,94 | 81,94 | class Discriminator:
"""Class representing a Discriminator."""
def __init__(self, name, params):
"""Initialize a Discriminator object
Args:
name (str): The name of the discriminator
params: The parameters of the discriminator
"""
self.name = name
... | class Discriminator:
"""Class representing a Discriminator."""
def __init__(self, name, params):
"""Initialize a Discriminator object
Args:
name (str): The name of the discriminator
params: The parameters of the discriminator
"""
self.name = name
... | return cls(**data)
| """Create a new Discriminator object from a dictionary.
Args:
data (dict): A dictionary representing the Discriminator
to create. It will be in the same format as output by
:meth:`to_dict`.
Returns:
Discriminator: The Di... | 2 | 267 | 14 | 281 | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... | # This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.