I’m not really sure what that would entail, but I realized I could just copy the values of the tensor (duh). Might not be as cute as a solution with combiners, but it works. Probably not the most efficient method either, but I’m only using it for small bond dimension MPSs.
function electron_to_fermion_site(t::ITensor, es::Index, fup::Index, fdn::Index)::ITensor
indices = inds(t)
nonSiteInds = [i for i in indices if i != es]
t = permute(t, nonSiteInds..., es)
newInds = copy(nonSiteInds)
push!(newInds, fup, fdn)
newT = ITensors.BlockSparseTensor(eltype(t), Block{length(newInds)}[], newInds)
for coords in CartesianIndex([1 for _ in nonSiteInds]...):CartesianIndex([dim(i) for i in nonSiteInds]...)
newT[coords.I..., 1, 1] = t[coords.I..., 1]
newT[coords.I..., 2, 1] = t[coords.I..., 2]
newT[coords.I..., 1, 2] = t[coords.I..., 3]
newT[coords.I..., 2, 2] = t[coords.I..., 4]
end
return itensor(newT)
end