jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
477 stars 107 forks source link

Typo in mps_gate_with_mpo_lazy #246

Closed hettahetta closed 1 month ago

hettahetta commented 1 month ago

What happened?

The function mps_gate_with_mpo_lazy calls tensor_network_apply_op_vec with parameters tn_op=mpo, tn_vec=mps, which results in an error. Correct way would be A=mpo, x=mps.

What did you expect to happen?

No response

Minimal Complete Verifiable Example

import quimb.tensor as qtn
import numpy as np

num_qubits = 5
psi = np.array([1, 0, 0, 0])
mps = qtn.MPS_product_state(
    [
        psi,
    ]
    * num_qubits,
    site_ind_id="q{}",
)
mpo = qtn.MPO_identity(num_qubits, phys_dim=4)

mps = qtn.tensor_1d_compress.mps_gate_with_mpo_lazy(mps=mps, mpo=mpo)

Relevant log output

1485 def mps_gate_with_mpo_lazy(mps, mpo, inplace=False):
   1486     """Apply an MPO to an MPS lazily, i.e. nothing is contracted, but the new
   1487     TN object has the same outer indices as the original MPS.
   1488     """
-> 1489     return tensor_network_apply_op_vec(
   1490         tn_op=mpo, tn_vec=mps, contract=False, inplace=inplace
   1491     )

TypeError: tensor_network_apply_op_vec() missing 2 required positional arguments: 'A' and 'x'

Anything else we need to know?

No response

Environment

quimb 1.8.3

jcmgray commented 1 month ago

Thanks for finding this @hettahetta, will fix in a bit, unless you want to open an PR yourself.