Skip to content

Commit

Permalink
Clarify input to import_operator and import_state in doc string (#4476)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiffafox authored Aug 15, 2023
1 parent e93fc1b commit ea624e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/code/qml_qchem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ number observables.
.. automodapi:: pennylane.qchem
:no-heading:
:include-all-objects:
:skip: taper, symmetry_generators, paulix_ops, import_operator
:skip: taper, symmetry_generators, paulix_ops, import_operator, import_state

Differentiable Hartree-Fock
---------------------------
Expand Down
3 changes: 3 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ array([False, False])
* `qml.import_state` is now accounted for in `doc/introduction/chemistry.rst`, adding the documentation for the function.
[(#4461)](https://github.com/PennyLaneAI/pennylane/pull/4461)

* Input types and sources for external wavefunctions and operators for `qml.import_state`
and `qml.import_operator` are clarified. [(#4476)](https://github.com/PennyLaneAI/pennylane/pull/4476)

<h3>Bug fixes 🐛</h3>

* Allow sparse matrix calculation of `SProd`s containing a `Tensor`. When using
Expand Down
10 changes: 7 additions & 3 deletions pennylane/qchem/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ def _openfermion_pennylane_equivalent(
def import_operator(qubit_observable, format="openfermion", wires=None, tol=1e010):
r"""Convert an external operator to a PennyLane operator.
The external format currently supported is openfermion.
We currently support [openfermion](https://quantumai.google/openfermion) operators: the function accepts most types of
OpenFermion qubit operators, such as those corresponding to Pauli words and sums of Pauli words.
Args:
qubit_observable: external qubit operator that will be converted
Expand All @@ -316,7 +317,7 @@ def import_operator(qubit_observable, format="openfermion", wires=None, tol=1e01
If ``None``, the identity map (e.g., ``0->0, 1->1, ...``) will be used.
tol (float): Tolerance in `machine epsilon <https://numpy.org/doc/stable/reference/generated/numpy.real_if_close.html>`_
for the imaginary part of the coefficients in ``qubit_observable``.
Coefficients with imaginary part less than 2.22e-16*tol are considered to be real.
Coefficients with imaginary part less than :math:`(2.22 \cdot 10^{-16}) \cdot \text{tol}` are considered to be real.
Returns:
(.Operator): PennyLane operator representing any operator expressed as linear combinations of
Expand Down Expand Up @@ -564,8 +565,11 @@ def _ucisd_state(cisd_solver, tol=1e-15):
def import_state(solver, tol=1e-15):
r"""Convert an external wavefunction to a state vector.
Currently, the only accepted source of wavefunctions is the PySCF library.
The restricted and unrestricted CISD/CCSD methods are supported.
Args:
solver: external wavefunction object that will be converted
solver: external wavefunction object (e.g. PySCF Solver object) that will be converted
tol (float): the tolerance for discarding Slater determinants based on their coefficients
Raises:
Expand Down

0 comments on commit ea624e0

Please sign in to comment.