From 581419d1eca9be002e8d681fb8bd9a8556e84c76 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Wed, 26 Jun 2024 21:47:26 +0200 Subject: [PATCH] Fix testing of isolated systems --- lib/AtomsBaseTesting/src/AtomsBaseTesting.jl | 8 ++++++-- lib/AtomsBaseTesting/test/runtests.jl | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/AtomsBaseTesting/src/AtomsBaseTesting.jl b/lib/AtomsBaseTesting/src/AtomsBaseTesting.jl index 97942de..463094e 100644 --- a/lib/AtomsBaseTesting/src/AtomsBaseTesting.jl +++ b/lib/AtomsBaseTesting/src/AtomsBaseTesting.jl @@ -22,7 +22,11 @@ function test_approx_eq(s::AbstractSystem, t::AbstractSystem; @test method(s) == method(t) end - @test maximum(map(rnorm, bounding_box(s), bounding_box(t))) < rtol + if isinfinite(s) + @test isinfinite(t) + else + @test maximum(map(rnorm, bounding_box(s), bounding_box(t))) < rtol + end for method in (position, atomic_mass) @test maximum(map(rnorm, method(s), method(t))) < rtol @test rnorm(method(s, 1), method(t, 1)) < rtol @@ -84,7 +88,7 @@ function test_approx_eq(s::AbstractSystem, t::AbstractSystem; if s[prop] isa Quantity @test rnorm(s[prop], t[prop]) < rtol - elseif prop in (:bounding_box, ) + elseif prop in (:bounding_box, ) && !isinfinite(s) @test maximum(map(rnorm, s[prop], t[prop])) < rtol else @test s[prop] == t[prop] diff --git a/lib/AtomsBaseTesting/test/runtests.jl b/lib/AtomsBaseTesting/test/runtests.jl index eb63646..e9bb024 100644 --- a/lib/AtomsBaseTesting/test/runtests.jl +++ b/lib/AtomsBaseTesting/test/runtests.jl @@ -91,5 +91,13 @@ include("testmacros.jl") @testpass test_approx_eq(case.system, case.system) end + @testset "test_approx_eq for isolated molecules" begin + hydrogen = isolated_system([ + :H => [0, 0, 0.]u"Å", + :H => [0, 0, 1.]u"Å", + ]) + test_approx_eq(hydrogen, hydrogen) + end + # TODO More tests would be useful end