Skip to content

Commit

Permalink
fix comment about returns and some small mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
zwgsyntax committed Jul 1, 2021
1 parent 119fd05 commit ea90a2b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 31 deletions.
4 changes: 2 additions & 2 deletions mindquantum/hiqfermion/transforms/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ def parity(self):
stores the initial occupation number nonlocally.
with the formular:
..math::
.. math::
|f_{M−1}, f_{M−2}, . . . , f_0\rangle → |q_{M−1}, q_{M−2}, . . . , q_0\rangle,
where :math:`q_{m} = |(\sum{i,0,m-1}f_{i}) mod 2 \rangle`.
Basically, this formular could be written as this,
..math::
.. math::
p_{i} = \sum{[\pi_{n}]_{i,j}} f_{j},
Expand Down
2 changes: 1 addition & 1 deletion mindquantum/nn/mindquantum_ansatz_only_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def final_state(self, measurements=None):
will be used. Default: None.
Returns:
numpy.ndarray: the final quantum state.
numpy.ndarray, the final quantum state.
"""
fake_data = Tensor(np.array([]).astype(np.float32))
return super().final_state(fake_data,
Expand Down
2 changes: 1 addition & 1 deletion mindquantum/nn/mindquantum_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def final_state(self,
will be used. Default: None.
Returns:
numpy.ndarray: the final quantum state.
numpy.ndarray, the final quantum state.
"""
if circuit is None:
circuit = self.circuit
Expand Down
2 changes: 1 addition & 1 deletion mindquantum/ops/_base_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def __iadd__(self, operator):
operator (QubitOperator): The operator to add.
Returns:
sum (QubitOperator): Mutated self.
sum (QubitOperator), Mutated self.
Raises:
TypeError: Cannot add invalid operator type.
Expand Down
2 changes: 1 addition & 1 deletion mindquantum/ops/fermion_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _normal_ordered_term(term, coefficient):
r"""Return the normal ordered term of the FermionOperator with high index
and creation operator in front.
eg. a_3\dagger a_2\dagger a_1 a_0
eg. :math:`a_3\dagger a_2\dagger a_1 a_0`
"""
term = list(term)
Expand Down
12 changes: 6 additions & 6 deletions mindquantum/ops/polynomial_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def __iadd__(self, addend):
addend (PolynomialTensor): The addend.
Returns:
sum (PolynomialTensor): Mutated self.
sum (PolynomialTensor), Mutated self.
Raises:
TypeError: Cannot add invalid addend type.
Expand Down Expand Up @@ -265,7 +265,7 @@ def __add__(self, addend):
added(PolynomialTensor): The addend.
Returns:
sum (PolynomialTensor): un-mutated self, but has new instance
sum (PolynomialTensor), un-mutated self, but has new instance
Raises:
TypeError: Cannot add invalid operator type.
Expand All @@ -288,7 +288,7 @@ def __isub__(self, subtractend):
subtractend (PolynomialTensor): subtractend.
Returns:
subtract (PolynomialTensor): Mutated self.
subtract (PolynomialTensor), Mutated self.
Raises:
TypeError: Cannot sub invalid addend type.
Expand Down Expand Up @@ -319,7 +319,7 @@ def __sub__(self, subtractend):
subtractend(PolynomialTensor): The subtractend.
Returns:
subtractend (PolynomialTensor): un-mutated self,
subtractend (PolynomialTensor), un-mutated self,
but has new instance
Raises:
Expand All @@ -336,7 +336,7 @@ def __imul__(self, multiplier):
terms (same operator).
Args:
multiplier(complex, float, or PolynomialTensor): multiplier
multiplier(complex, float, or PolynomialTensor): multiplier
Returns:
products(PolynomialTensor)
Expand Down Expand Up @@ -382,7 +382,7 @@ def __mul__(self, multiplier):
multiplier (PolynomialTensor): The multiplier to multiply.
Returns:
multiply (PolynomialTensor): un-Mutated self.
multiply (PolynomialTensor), un-Mutated self.
Raises:
TypeError: Cannot multiply invalid type.
Expand Down
6 changes: 3 additions & 3 deletions mindquantum/ops/qubit_excitation_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def to_qubit_operator(self):
Convert the Qubit excitation operator to the equivalent Qubit operator.
Returns:
qubit_operator(QubitOperator): The corresponding QubitOperator
according to the definition of Qubit excitation operators.
qubit_operator(QubitOperator), The corresponding QubitOperator
according to the definition of Qubit excitation operators.
Examples:
>>> from mindquantum.ops import QubitExcitationOperator
Expand Down Expand Up @@ -268,7 +268,7 @@ def normal_ordered(self):
Returns:
QubitExcitationOperator, the normal ordered operator.
Exmples:
Examples:
>>> from mindquantum.ops import QubitExcitationOperator
>>> op = QubitExcitationOperator("7 1^")
>>> op
Expand Down
11 changes: 6 additions & 5 deletions mindquantum/third_party/interaction_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,23 @@ class InteractionOperator(PolynomialTensor):
and parity. In this module, the stored coefficient could be represented the
molecualr Hamiltonians througth the FermionOperator class.
Notes:
Note:
The operators stored in this class has the form:
.. math::
constant + \sum_{p, q} h_[p, q] a^\dagger_p a_q +
\sum_{p, q, r, s} h_[p, q, r, s] a^\dagger_p a^\dagger_q a_r a_s.
constant + \sum_{p, q} h_[p, q] a^\dagger_p a_q +
\sum_{p, q, r, s} h_[p, q, r, s] a^\dagger_p a^\dagger_q a_r a_s.
Args:
constant (number.Numbers): A constant term in the operator given as a
float. For instance, the nuclear repulsion energy.
one_body_tensor (numpy.array): The coefficients of the one-body terms (h[p, q]).
This is an n_qubits x n_qubits numpy array of floats. By default we
store the numpy array with keys: a^\dagger_p a_q (1,0).
store the numpy array with keys: :math:`a^\dagger_p a_q` (1,0).
two_body_tensor (numpy.array): The coefficients of the two-body terms
(h[p, q, r, s]). This is an n_qubits x n_qubits x n_qubits x
n_qubits numpy array of floats.By default we store the numpy array
with keys: a^\dagger_p a^\dagger_q a_r a_s (1, 1, 0, 0).
with keys: :math:`a^\dagger_p a^\dagger_q a_r a_s` (1, 1, 0, 0).
"""
def __init__(self, constant, one_body_tensor, two_body_tensor):
# make sure only non-zero tensor elements exist in the normal-ordered
Expand Down
12 changes: 6 additions & 6 deletions mindquantum/third_party/unitary_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def uccsd_singlet_get_packed_amplitudes(single_amplitudes, double_amplitudes,
n_electrons(int): Number of electrons in the physical system.
Returns:
packed_amplitudes(list): List storing the unique single
and double excitation amplitudes for a singlet UCCSD operator.
The ordering lists unique single excitations before double
excitations.
packed_amplitudes(list), List storing the unique single
and double excitation amplitudes for a singlet UCCSD operator.
The ordering lists unique single excitations before double
excitations.
"""
n_spatial_orbitals = n_qubits // 2
n_occupied = int(numpy.ceil(n_electrons / 2))
Expand Down Expand Up @@ -116,8 +116,8 @@ def uccsd_singlet_generator(n_qubits, n_electrons, anti_hermitian=True):
rather than unitary variant, primarily for testing
Returns:
generator(FermionOperator): Generator of the UCCSD operator that
builds the UCCSD wavefunction.
generator(FermionOperator), Generator of the UCCSD operator that
builds the UCCSD wavefunction.
"""
if n_qubits % 2 != 0:
raise ValueError('The total number of spin-orbitals should be even.')
Expand Down
10 changes: 5 additions & 5 deletions mindquantum/utils/utils_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def count_qubits(operator):
FermionOperator or QubitOperator or QubitExcitationOperator.
Returns:
num_qubits (int): The minimum number of qubits on which operator acts.
num_qubits (int), The minimum number of qubits on which operator acts.
Raises:
TypeError: Operator of invalid type.
Expand Down Expand Up @@ -107,7 +107,7 @@ def _normal_ordered_term(term, coefficient):
r"""
return the normal order order of a fermion operator with
larger index and creation operator in front.
eg. a_4\dagger a3_\dagger a_2 a_1.
eg. :math:`a_4\dagger a3_\dagger a_2 a_1`.
"""
term = list(term)
ordered_term = FermionOperator()
Expand Down Expand Up @@ -175,7 +175,7 @@ def get_fermion_operator(operator):
"""Convert the tensor (PolynomialTensor) to FermionOperator.
Returns:
fermion_operator: An instance of the FermionOperator class.
fermion_operator, An instance of the FermionOperator class.
"""
fermion_operator = FermionOperator()

Expand Down Expand Up @@ -232,7 +232,7 @@ def hermitian_conjugated(operator):
Returns:
operator (Union[FermionOperator, QubitOperator, QubitExcitationOperator]),
the hermitian form of the input operator.
the hermitian form of the input operator.
Examples:
>>> from mindquantum.ops import QubitOperator
Expand Down Expand Up @@ -309,7 +309,7 @@ def sz_operator(n_spatial_orbitals):
n_spatial_orbitals (int): number of spatial orbitals (n_qubits // 2).
Returns:
operator (FermionOperator): corresponding to the sz operator over
operator (FermionOperator), corresponding to the sz operator over
n_spatial_orbitals.
Note:
Expand Down

0 comments on commit ea90a2b

Please sign in to comment.