Skip to content

Commit

Permalink
Fix bug with single_particle_density, integer vectors and `Composit…
Browse files Browse the repository at this point in the history
…eFS` (#225)

* Fix bug when using `single_particle_density` with composite addresses and integer vectors

* bump version

* fix normalization
  • Loading branch information
mtsch authored Nov 29, 2023
1 parent 63dbe32 commit 55ffbc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Rimu"
uuid = "c53c40cc-bd84-11e9-2cf4-a9fde2b9386e"
authors = ["Joachim Brand <j.brand@massey.ac.nz>"]
version = "0.10.3-dev"
version = "0.10.3"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand Down
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, 7, 0)
end
end
end
Expand Down

0 comments on commit 55ffbc7

Please sign in to comment.