Skip to content

Commit

Permalink
Fix bug when using single_particle_density with composite addresses…
Browse files Browse the repository at this point in the history
… and integer vectors
  • Loading branch information
mtsch committed Nov 28, 2023
1 parent 63dbe32 commit 9d95f82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/strategies_and_params/poststepstrategy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ julia> single_particle_density(v; component=1)
"""
function single_particle_density(dvec; component=0)
K = keytype(dvec)
V = valtype(dvec)
V = float(valtype(dvec))
M = num_modes(K)
N = num_particles(K)

Expand All @@ -283,12 +283,12 @@ function single_particle_density(dvec; component=0)
end

function single_particle_density(add::SingleComponentFockAddress; component=0)
return Tuple(onr(add))
return float.(Tuple(onr(add)))
end
function single_particle_density(add::Union{CompositeFS,BoseFS2C}; component=0)
if component == 0
return Float64.(Tuple(sum(onr(add))))
return float.(Tuple(sum(onr(add))))
else
return Float64.(Tuple(onr(add)[component]))
return float.(Tuple(onr(add)[component]))
end
end
1 change: 1 addition & 0 deletions test/lomc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ using DataFrames
@test single_particle_density(add) == (1, 3, 3)
@test single_particle_density(add; component=1) == (1, 2, 3)
@test single_particle_density(add; component=2) == (0, 1, 0)
@test single_particle_density(DVec(add => 1); component=2) == (0, 1, 0)
end
end
end
Expand Down

0 comments on commit 9d95f82

Please sign in to comment.