Skip to content

Commit

Permalink
modify API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhan committed Feb 21, 2024
1 parent 076481a commit cce7478
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ mindquantum.algorithm.qaia.LQA

.. py:method:: update(beta1=0.9, beta2=0.999, epsilon=10e-8)
Adam动力学演化。

参数:
- **beta1** (float) - Beta1参数。默认值: ``0.9``。
- **beta2** (float) - Beta2参数。默认值: ``0.999``。
- **epsilon** (float) - Epsilon参数。默认值: ``10e-8``。

Adam动力学演化。
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ mindquantum.core.operators.FermionOperator
- **n_qubits** (int) - 结果矩阵的总量子比特数。如果是None,则该值将是最大局域量子比特数。默认值: ``None``。
- **pr** (ParameterResolver, dict, numpy.ndarray, list, numbers.Number) - 含参费米子算符的参数。默认值: ``None``。

.. py:method:: params_name
:property:

获取费米子算符的所有参数。

.. py:method:: normal_ordered()
返回FermionOperator的规范有序形式。
Expand All @@ -151,6 +146,11 @@ mindquantum.core.operators.FermionOperator

检查当前费米子是否是参数化的。

.. py:method:: params_name
:property:

获取费米子算符的所有参数。

.. py:method:: real
:property:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ mindquantum.core.operators.QubitOperator
- **n_qubits** (int) - 结果矩阵的量子比特数目。如果是None,则该值将是最大局域量子比特数。默认值: ``None``。
- **pr** (ParameterResolver, dict, numpy.ndarray, list, numbers.Number) - 含参玻色子算符的参数。默认值: ``None``。

.. py:method:: params_name
.. py:method:: parameterized
:property:

获取玻色子算符的所有参数
检查当前玻色子是否是参数化的

.. py:method:: parameterized
.. py:method:: params_name
:property:

检查当前玻色子是否是参数化的
获取玻色子算符的所有参数

.. py:method:: real
:property:
Expand Down
15 changes: 9 additions & 6 deletions docs/api_python/utils/mindquantum.utils.random_insert_gates.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
mindquantum.utils.random_insert_gates
======================================

.. py:function:: mindquantum.utils.random_insert_gates(circuit, gates, nums, focus_on=None, with_ctrl=True, after_measure=False, shots=1, seed=None)
.. py:function:: mindquantum.utils.random_insert_gates(circuit: Circuit, gates: BasicGate | list[BasicGate], nums: int | list[int], focus_on: int | list[int] | None = None, with_ctrl: bool = True, after_measure: bool = False, shots: int = 1, seed: int | None = None)
将指定数量的单量子比特门插入到量子线路中的随机位置。

参数:
- **circuit** (Circuit) - 待随机插入量子门的量子线路。
- **gates** (Union[BasicGate, List[BasicGate]]) - 所有待插入的量子门。
- **nums** (Union[int, List[int]]) - 每种量子门插入的数量。
- **focus_on** (Optional[Union[int, List[int]]]) - 只将量子门作用在 focus_on 比特上。如果为 None,则作用在量子线路的所有比特上。默认值: None。
- **with_ctrl** (bool) - 是否在控制位上插入量子门。默认值: True。
- **after_measure** (bool) - 是否在测量门后插入量子门。默认值: False。
- **shots** (int) - 随机采样量子线路的数量。默认值: 1。
- **seed** (Optional[int]) - 生成插入位置的随机数种子。默认值: None。
- **focus_on** (Union[int, List[int]], 可选) - 只将量子门作用在 focus_on 比特上。如果为 None,则作用在量子线路的所有比特上。默认值: None。
- **with_ctrl** (bool, 可选) - 是否在控制位上插入量子门。默认值: True。
- **after_measure** (bool, 可选) - 是否在测量门后插入量子门。默认值: False。
- **shots** (int, 可选) - 随机采样量子线路的数量。默认值: 1。
- **seed** (int, 可选) - 生成插入位置的随机数种子。默认值: None。

返回:
一个可以产生量子线路的生成器。
11 changes: 6 additions & 5 deletions mindquantum/utils/f.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ def random_insert_gates(
gates (Union[BasicGate, List[BasicGate]]): The selected single-qubit gates to be inserted.
nums (Union[int, List[int]]):The number of each gate to be inserted.
Note that the length of the nums should be equal to that of the gates.
with_ctrl (bool): Whether insert gates for control qubits. Default: ``True``.
focus_on (Optional[Union[int, List[int]]]): only insert gates on ``focus_on`` qubits. If ``None``, insert to
with_ctrl (bool, optional): Whether insert gates for control qubits. Default: ``True``.
focus_on (Union[int, List[int]], optional): only insert gates on ``focus_on`` qubits. If ``None``, insert to
all qubits of selected gates. Default: ``None``.
after_measure (bool): Whether insert gates after measure gates. Default: ``False``.
shots (int): How many shots you want to sampling this circuit. Default: ``1``.
seed (int): Random seed for random sampling. If ``None``, seed will be a random int number. Default: ``None``.
after_measure (bool, optional): Whether insert gates after measure gates. Default: ``False``.
shots (int, optional): How many shots you want to sampling this circuit. Default: ``1``.
seed (int, optional): Random seed for random sampling.
If ``None``, seed will be a random int number. Default: ``None``.
Returns:
A generator that can generate quantum circuits.
Expand Down

0 comments on commit cce7478

Please sign in to comment.