Skip to content

Commit d91dbdd

Browse files
lchmtsch
andcommitted
Unified ModeMap Type (#330)
1. Add tests to new methods according to suggestion Co-authored-by: mtsch <[email protected]>
1 parent aed71ab commit d91dbdd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/BitStringAddresses/fockaddress.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ A unified storage structure for indices of `SingleComponentFockAddress`.
238238
It stores the FSIndex of corresponding address as an `AbstractVector` compatible with
239239
[`excitation`](@ref) - [`BoseFSIndex`](@ref) or [`FermiFSIndex`](@ref).
240240
241-
This struct is not intended to construct directly. Use [`occupied_mode_map`](@ref) or
241+
This struct is not intended to be constructed directly. Use [`occupied_mode_map`](@ref) or
242242
[`unoccupied_mode_map`](@ref) to obtain an instance.
243243
244244
See also [`SingleComponentFockAddress`](@ref).

test/BitStringAddresses.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using Rimu
22
using Rimu.BitStringAddresses
33
using Rimu.BitStringAddresses: num_chunks, chunks
44
using Rimu.BitStringAddresses: remove_ghost_bits, has_ghost_bits
5-
using Rimu.BitStringAddresses: occupied_modes, update_component
5+
using Rimu.BitStringAddresses: occupied_modes, occupied_mode_map, unoccupied_modes, unoccupied_mode_map, update_component
66
using Rimu.BitStringAddresses: parse_address
77
using Rimu.BitStringAddresses: destroy, create
88
using Random
@@ -229,6 +229,11 @@ end
229229

230230
@test collect(occupied_modes(middle_empty)) == [[2, 1, 0], [8, 127, 128]]
231231
end
232+
@testset "occupied_mode_map" begin
233+
for b in (middle_full, middle_empty, two_full)
234+
@test occupied_mode_map(b) == collect(occupied_modes(b))
235+
end
236+
end
232237
@testset "Randomized tests" begin
233238
# Note: the random number for these tests will be the same everytime. This is still
234239
# an ok way to look for errors.
@@ -354,9 +359,18 @@ end
354359
for o in (small, big, giant)
355360
f = FermiFS(o)
356361
sites = collect(occupied_modes(f))
362+
@test occupied_mode_map(f) == sites
357363
@test getproperty.(sites, :mode) == findall((0), onr(f))
358364
end
359365
end
366+
@testset "unoccupied_modes" begin
367+
for o in (small, big, giant)
368+
f = FermiFS(o)
369+
sites = collect(unoccupied_modes(f))
370+
@test unoccupied_mode_map(f) == sites
371+
@test getproperty.(sites, :mode) == findall(==(0), onr(f))
372+
end
373+
end
360374
@testset "Randomized Tests" begin
361375
function rand_onr_fermi(N, M)
362376
return SVector{M}(shuffle([ones(Int,N); zeros(Int,M - N)]))

0 commit comments

Comments
 (0)