correlation matrix of complex operators

Hello,
this is my first post so forgive me all the mistakes. I am reaching out to you because since installing julia_1.8 the correlation matrix i defined, does not work.

First I define a Sx operator:

function ITensors.op(::OpName"Sy", ::SiteType"Electron", s1::Index) 
    
    S_y = (op("S+", s1) - op("S-", s1))/(2im);
    return S_y
end

and then I want to calculate a correlation matrix

N = 6;
Ne=N;
sites = siteinds("Electron", 2*N, conserve_qns=true);

states = ["0" for n=1:2*N];
for n in 1:trunc(Int,Ne/2.0)
     states[n] = "Up";
end

for n in trunc(Int,Ne/2.0)+1:Ne
     states[n] = "Dn";
end
shuffle!(states);
psi0 = randomMPS(sites,states);

fincorr = correlation_matrix(psi0,"Sy","Sy");

But I get a following error: InexactError: Float64(0.0 - 0.5im) which refers to the complex value of the S_y operator.

Do you have any idea why this occurs? And is there a way to by-pass it? I am pretty sure my code worked before on older julia’s version.

Thanks in advance for any help,
Tymek

Hi, thanks for the report, this is related to a known issue: [ITensors] [BUG] Can't measure complex operator on real MPS in expect · Issue #1019 · ITensor/ITensors.jl · GitHub.

For now, it should work if you use correlation_matrix(complex(psi0), "Sy", "Sy").