Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing of isolated systems #105

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading