jcmgray / quimb

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

tensor_1d partial trace minor bug #154

Open jerrylvx opened 1 year ago

jerrylvx commented 1 year ago

What happened?

the partial trace function of the tensor_1d module contains a bug that causes it to fail when the kept subsystem is the last site of the system. This can be fixed by adding the lines

  # if single site a single tensor is produced
                if isinstance(rho, Tensor):
                    rho = TensorNetwork([rho])

in the location below

 for i in self.gen_site_coos():
            if i in keep:
                #      |
                #     -o-             |
                # ... -o- ... -> ... -O- ...
                #     i|             i|
                # ADD CODE HERE
                rho ^= self.site_tag(i)

What did you expect to happen?

No response

Minimal Complete Verifiable Example

No response

Relevant log output

No response

Anything else we need to know?

No response

Environment

quimb 1.3.0+393.g28dc9dd

jcmgray commented 1 year ago

Hi @jerrylvx, any interest in submitting this fix as a PR?