Skip to content

Commit

Permalink
fix issue reported by Ali for primitive of Fourier lattice (conversio…
Browse files Browse the repository at this point in the history
…n to integer issue)
  • Loading branch information
thchr committed Sep 26, 2024
1 parent b9e2bcd commit e58d325
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lattices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ function transform(flat::AbstractFourierLattice{D}, P::AbstractMatrix{<:Real}) w
# transform all k-vecs in the orbits
for (i, orb) in enumerate(orbits)
for (j, k) in enumerate(orb)
orbits′[i][j] = convert(SVector{D, Int}, P'*k)
k′ = P'*k
int_k′ = round.(Int, k′)
if !isapprox(k′, k, atol=DEFAULT_ATOL)
error("unexpectedly obtained non-integer k-vector in orbit")
end
orbits′[i][j] = int_k′::SVector{D,Int}
end
end
# --- Comment regarding the `convert(SVector{D, Int}, ...)` call above: ---
Expand Down
4 changes: 4 additions & 0 deletions test/lattices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ using Test
# test that a primitivize -> conventionalize cycle leaves the lattice unchanged
@test flat conventionalize(flat′, cntr)
end

# convert-to-integer bug found by Ali
flat = levelsetlattice(sgnum, Val(3), ntuple(_->2, Val(3)))
@test primitivize(flat, centering(sgnum)) isa UnityFourierLattice{3} # = doesn't throw
end

0 comments on commit e58d325

Please sign in to comment.