From e58d3251590713fabdd991866c821002d4e89cb5 Mon Sep 17 00:00:00 2001 From: Thomas Christensen Date: Thu, 26 Sep 2024 16:38:15 +0200 Subject: [PATCH] fix issue reported by Ali for primitive of Fourier lattice (conversion to integer issue) --- src/lattices.jl | 7 ++++++- test/lattices.jl | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lattices.jl b/src/lattices.jl index 02780ab1..b23f66cf 100644 --- a/src/lattices.jl +++ b/src/lattices.jl @@ -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: --- diff --git a/test/lattices.jl b/test/lattices.jl index ac38fd4d..051ec67f 100644 --- a/test/lattices.jl +++ b/test/lattices.jl @@ -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 \ No newline at end of file