Skip to content

Commit

Permalink
add specific tests for BitString and SortedParticleList
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsch committed Sep 18, 2023
1 parent 2aea78b commit e322566
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/BitStringAddresses/sortedparticlelist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ function SortedParticleList{N,M}() where {N,M}
T = select_int_type(M)
return SortedParticleList{N,M,T}(ones(SVector{N,T}))
end
function SortedParticleList(onr)
N = sum(onr)
M = length(onr)
T = select_int_type(M)
eltype(onr) <: Integer || throw(ArgumentError("the onr can only contain integers"))
any((0), onr) || throw(ArgumentError("all elements of the onr should be positive"))

return from_onr(SortedParticleList{N,M,T}, onr)
end
function from_onr(::Type{S}, onr) where {N,M,T,S<:SortedParticleList{N,M,T}}
spl = zeros(MVector{N,T})
curr = 1
Expand Down
2 changes: 2 additions & 0 deletions test/RimuIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ end
end
@testset "Addresses" begin
for addr in (
BitString{10}(0b1100110011),
SortedParticleList((1, 0, 1, 0, 0, 2, 3)),
near_uniform(BoseFS{10, 10}),
BoseFS(101, 5 => 10),
FermiFS((1,1,1,0,0,0)),
Expand Down

0 comments on commit e322566

Please sign in to comment.