Skip to content

Commit

Permalink
Fix testing of isolated systems (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst authored Jun 26, 2024
1 parent c53733c commit cc48fcc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/AtomsBaseTesting/src/AtomsBaseTesting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions lib/AtomsBaseTesting/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cc48fcc

Please sign in to comment.