From db315d5a4884a9b75410a4d9e6750382f6cca66a Mon Sep 17 00:00:00 2001 From: vinitha-balachandran Date: Mon, 4 Mar 2024 14:35:15 +0800 Subject: [PATCH 1/2] Adding docstring to quimb.py and eval_qu.py --- src/qibotn/backends/quimb.py | 2 +- src/qibotn/eval_qu.py | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/qibotn/backends/quimb.py b/src/qibotn/backends/quimb.py index 0a34eef..e697a58 100644 --- a/src/qibotn/backends/quimb.py +++ b/src/qibotn/backends/quimb.py @@ -59,7 +59,7 @@ class QuimbBackend(NumpyBackend): If ``None`` the default ``|00...0>`` state is used. Returns: - xxx. + list: Final state in the dense vector form after simulation of the circuit. """ import qibotn.eval_qu as eval diff --git a/src/qibotn/eval_qu.py b/src/qibotn/eval_qu.py index d6064e9..83e3a4e 100644 --- a/src/qibotn/eval_qu.py +++ b/src/qibotn/eval_qu.py @@ -3,7 +3,15 @@ import quimb.tensor as qtn def init_state_tn(nqubits, init_state_sv): - """Create a matrix product state directly from a dense vector.""" + """Create a matrix product state directly from a dense vector. + + Args: + nqubits (int): Total number of qubits in the circuit. + init_state_sv (list): Initial state in the dense vector form. + + Returns: + list: Matrix product state representation of the dense vector. + """ dims = tuple(2 * np.ones(nqubits, dtype=int)) @@ -11,9 +19,17 @@ def init_state_tn(nqubits, init_state_sv): def dense_vector_tn_qu(qasm: str, initial_state, mps_opts, backend="numpy"): - """Evaluate QASM with Quimb. + """Evaluate circuit in QASM format with Quimb. - backend (quimb): numpy, cupy, jax. Passed to ``opt_einsum``. + Args: + qasm (str): QASM program. + initial_state (list): Initial state in the dense vector form. If ``None`` the default ``|00...0>`` state is used. + mps_opts (dict): Parameters to tune the gate_opts for mps settings in ``class quimb.tensor.circuit.CircuitMPS``. + backend (str): Backend to perform the contraction with, e.g. ``numpy``, ``cupy``, ``jax``. Passed to ``opt_einsum``. + + Returns: + list: Amplitudes of final state after the simulation of the circuit. + """ if initial_state is not None: From a8c93cc726fcf2f24bdbb6289a20bddb79d7f830 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 06:35:29 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/qibotn/eval_qu.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/qibotn/eval_qu.py b/src/qibotn/eval_qu.py index 83e3a4e..6cb9f39 100644 --- a/src/qibotn/eval_qu.py +++ b/src/qibotn/eval_qu.py @@ -5,12 +5,12 @@ import quimb.tensor as qtn def init_state_tn(nqubits, init_state_sv): """Create a matrix product state directly from a dense vector. - Args: - nqubits (int): Total number of qubits in the circuit. - init_state_sv (list): Initial state in the dense vector form. + Args: + nqubits (int): Total number of qubits in the circuit. + init_state_sv (list): Initial state in the dense vector form. - Returns: - list: Matrix product state representation of the dense vector. + Returns: + list: Matrix product state representation of the dense vector. """ dims = tuple(2 * np.ones(nqubits, dtype=int)) @@ -21,15 +21,14 @@ def init_state_tn(nqubits, init_state_sv): def dense_vector_tn_qu(qasm: str, initial_state, mps_opts, backend="numpy"): """Evaluate circuit in QASM format with Quimb. - Args: - qasm (str): QASM program. - initial_state (list): Initial state in the dense vector form. If ``None`` the default ``|00...0>`` state is used. - mps_opts (dict): Parameters to tune the gate_opts for mps settings in ``class quimb.tensor.circuit.CircuitMPS``. - backend (str): Backend to perform the contraction with, e.g. ``numpy``, ``cupy``, ``jax``. Passed to ``opt_einsum``. + Args: + qasm (str): QASM program. + initial_state (list): Initial state in the dense vector form. If ``None`` the default ``|00...0>`` state is used. + mps_opts (dict): Parameters to tune the gate_opts for mps settings in ``class quimb.tensor.circuit.CircuitMPS``. + backend (str): Backend to perform the contraction with, e.g. ``numpy``, ``cupy``, ``jax``. Passed to ``opt_einsum``. - Returns: - list: Amplitudes of final state after the simulation of the circuit. - + Returns: + list: Amplitudes of final state after the simulation of the circuit. """ if initial_state is not None: