Skip to content

Commit 09730d3

Browse files
committed
<feat>修改代码中的test
1 parent 9500cb9 commit 09730d3

24 files changed

Lines changed: 28 additions & 139 deletions

Tutorials/source/GettingStarted.rst

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ It contains many practical quantum application algorithms. Installation and use
1111
Configuration
1212
>>>>>>>>>>>>>>>>>>>
1313

14-
pyqpanda_alg uses C++ as the host language, and its environmental requirements for the system are as follows:
14+
pyqpanda_alg's environmental requirements for the system are as follows:
1515

1616
Windows
1717
---------------------
1818
.. list-table::
1919

2020
* - software
2121
- version
22-
* - `Microsoft Visual C++ Redistributable x64`_
23-
- 2019
2422
* - Python
2523
- >= 3.11 && <= 3.13
2624

@@ -34,16 +32,4 @@ Linux
3432
* - GCC
3533
- >= 7.5
3634
* - Python
37-
- >= 3.11 && <= 3.13
38-
39-
40-
Install
41-
>>>>>>>>>>>>>>>>>
42-
43-
If you have already installed the python environment and the pip tool, enter the following command in the terminal or console:
44-
45-
.. code-block:: python
46-
47-
pip install pyqpanda_alg
48-
49-
.. note:: If you encounter permission problems under linux, you need to add ``sudo``
35+
- >= 3.11 && <= 3.13

Tutorials/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# -- Project information -----------------------------------------------------
2020

2121
project = 'pyqpanda-algorithm'
22-
copyright = '2023, OriginQC'
22+
copyright = '2026, OriginQC'
2323
author = 'OriginQC'
2424

2525
# The short X.Y version

Tutorials/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Overall, it provides a standardized set of tools for developers, allowing them t
3030

3131
autoapi/pyqpanda_alg/QAOA/index
3232
autoapi/pyqpanda_alg/QARM/index
33-
autoapi/pyqpanda_alg/QAlgBase/index
3433
autoapi/pyqpanda_alg/QKmeans/index
3534
autoapi/pyqpanda_alg/QPCA/index
3635
autoapi/pyqpanda_alg/QSVM/index

pyqpanda-algorithm/pyqpanda_alg/QAOA/qaoa.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ def run_qaoa_circuit(self, gammas, betas, shots=-1):
482482
483483
.. code-block:: python
484484
485-
import pyqpanda as pq
486485
import sympy as sp
487486
from pyqpanda_alg.QAOA.qaoa import *
488487

pyqpanda-algorithm/pyqpanda_alg/QSVM/quantum_kernel_svm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def evaluate(self, x_vec: np.ndarray, y_vec: np.ndarray = None) -> np.ndarray:
209209
210210
import os
211211
import numpy as np
212-
import pyqpanda as pq
213212
from sklearn.svm import SVC
214213
import matplotlib
215214
try:

pyqpanda-algorithm/setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
requirements = open('requirements.txt').readlines()
77
requirements = [r.strip() for r in requirements]
88

9-
109
is_win = (platform.system() == 'Windows')
1110
if is_win:
1211
pd_files = ['*.pyd', '*.dll', '*.pyi']
@@ -20,10 +19,9 @@
2019
license = "Apache Licence",
2120
author = "OriginQ",
2221
install_requires=requirements,
23-
description= "A Quantum Algorithm Development and Runtime Environment Kit, based on pyqpanda.",
22+
description= "A Quantum Algorithm Development and Runtime Environment Kit, based on pyqpanda3.",
2423
packages = find_packages(),
2524

26-
py_modules = ['psi4_wrapper'],
2725
package_data={
2826
'':pd_files
2927
},
@@ -39,4 +37,4 @@
3937
"Programming Language :: Python :: 3.12",
4038
"Programming Language :: Python :: 3.13"
4139
],
42-
)
40+
)

test/QAOA/Test_complete_xy_mixer.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33
# import pytest
44
# import numpy as np
55
#
6-
# # 添加项目路径到系统路径
76
# sys.path.append((Path.cwd().parent.parent).__str__())
87
#
98
# from pyqpanda3.core import QProg, RX, CPUQVM
109
# from pyqpanda_alg.QAOA import default_circuits
1110
#
1211
#
1312
# class TestCompleteXYMixer:
14-
# """测试 complete_xy_mixer 接口"""
1513
#
1614
# def setup_method(self):
17-
# """测试前的初始化"""
1815
# self.machine = CPUQVM()
1916
#
2017
# def calculate_hamming_weight_distribution(self, prob_dict, max_weight):
21-
# """计算汉明权重分布"""
2218
# weight_probs = {}
2319
# for weight in range(max_weight + 1):
2420
# prob = sum(value for key, value in prob_dict.items()
@@ -27,48 +23,37 @@
2723
# return weight_probs
2824
#
2925
# def test_complete_xy_mixer_hamming_weight_preservation(self):
30-
# """测试XY mixer应该保持汉明权重"""
3126
# n_qubits = 4
3227
# prog = QProg(n_qubits)
3328
# qubits = prog.qubits()
3429
#
35-
# # 创建初始状态 - 使用随机RX门创建复杂初始状态
3630
# for q in qubits:
3731
# prog << RX(q, np.random.random() * 2 * np.pi)
3832
#
39-
# # 获取初始状态的概率分布
4033
# self.machine.run(prog, shots=1)
4134
# original_result = self.machine.result().get_prob_dict()
4235
#
43-
# # 计算初始汉明权重分布
4436
# original_weight_probs = self.calculate_hamming_weight_distribution(original_result, n_qubits)
4537
#
4638
# # 应用 complete_xy_mixer
4739
# beta = np.pi / 5
4840
# circuit = default_circuits.complete_xy_mixer(qubits, beta)
4941
# prog << circuit
5042
#
51-
# # 获取应用mixer后的概率分布
5243
# self.machine.run(prog, shots=1)
5344
# final_result = self.machine.result().get_prob_dict()
5445
#
55-
# # 计算最终汉明权重分布
5646
# final_weight_probs = self.calculate_hamming_weight_distribution(final_result, n_qubits)
57-
#
58-
# # 打印详细的权重分布变化
5947
# print("\nHamming weight distribution comparison:")
6048
# for weight in range(n_qubits + 1):
6149
# original_prob = original_weight_probs.get(weight, 0)
6250
# final_prob = final_weight_probs.get(weight, 0)
6351
# print(f"Hamming weight {weight}: {original_prob:.4f} -> {final_prob:.4f}")
6452
#
65-
# # XY mixer应该保持汉明权重(在统计误差范围内)
66-
# # 由于有限shots和数值精度,允许一定的误差
67-
# tolerance = 0.05 # 5% 容忍度
53+
# tolerance = 0.05
6854
# assert abs(original_prob - final_prob) < tolerance, \
6955
# f"Hamming weight {weight} not preserved within tolerance: {original_prob:.4f} -> {final_prob:.4f}"
7056
#
7157
#
7258
# if __name__ == "__main__":
73-
# # 运行测试
7459
# pytest.main([__file__, "-v", "-s"])

test/QAOA/Test_default_circuits_linear_w_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@
6363
#
6464
#
6565
# if __name__ == "__main__":
66-
# # 运行测试
66+
# # run test
6767
# pytest.main([__file__, "-v"])

test/QAOA/Test_default_circuits_prepare_dicke_state.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# import pytest
44
# import numpy as np
55
#
6-
# # 添加项目路径到系统路径
76
# sys.path.append((Path.cwd().parent.parent).__str__())
87
#
98
# from pyqpanda_alg.QAOA import default_circuits
@@ -45,5 +44,5 @@
4544
#
4645
#
4746
# if __name__ == "__main__":
48-
# # 运行测试
47+
# # run test
4948
# pytest.main([__file__, "-v"])

test/QAOA/Test_dstate_linear_w_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@
5555
#
5656
#
5757
# if __name__ == "__main__":
58-
# # 运行测试
58+
# # run test
5959
# pytest.main([__file__, "-v"])

0 commit comments

Comments
 (0)