Skip to content

Commit

Permalink
Add :diagonal option to test_approx_equal (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejmeitz authored Jun 5, 2023
1 parent 144ea82 commit 8455523
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/AtomsBaseTesting/src/AtomsBaseTesting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ function make_test_system(D=3; drop_atprop=Symbol[], drop_sysprop=Symbol[],
box = [[1.54732, 0.0, 0.0],
[-0.807289, 0.4654985, 0.0],
[-0.500870, 0.5615117, 0.7928950]]u"Å"
elseif cellmatrix == :diagonal
box = [[1.54732, 0.0, 0.0],
[0.0, 0.4654985, 0.0],
[0.0, 0.0, 0.7928950]]u"Å"
else
box = [[-1.50304, 0.850344, 0.717239],
[ 0.36113, 0.008144, 0.814712],
[ 0.06828, 0.381122, 0.129081]]u"Å"
box = [[1.50304, 0.850344, 0.717239],
[ 0.36113, 1.008144, 0.814712],
[ 0.06828, 0.381122, 2.129081]]u"Å"
end
bcs = [Periodic(), Periodic(), DirichletZero()]
system = atomic_system(atoms, box, bcs; sysprop...)
Expand Down
11 changes: 10 additions & 1 deletion lib/AtomsBaseTesting/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,27 @@ include("testmacros.jl")
box = reduce(hcat, bounding_box(case.system))
@test UpperTriangular(box) != box
@test LowerTriangular(box) != box
@test Diagonal(box) != box
end
let case = make_test_system(; cellmatrix=:upper_triangular)
box = reduce(hcat, bounding_box(case.system))
@test UpperTriangular(box) == box
@test LowerTriangular(box) != box
@test Diagonal(box) != box
end
let case = make_test_system(; cellmatrix=:lower_triangular)
box = reduce(hcat, bounding_box(case.system))
@test UpperTriangular(box) != box
@test LowerTriangular(box) == box
@test Diagonal(box) != box
end

let case = make_test_system(; cellmatrix=:diagonal)
box = reduce(hcat, bounding_box(case.system))
@test Diagonal(box) == box
@test UpperTriangular(box) == box
@test LowerTriangular(box) == box
end

@test hasatomkey(make_test_system().system, :vdw_radius)
@test !hasatomkey(make_test_system(; drop_atprop=[:vdw_radius]).system, :vdw_radius)

Expand Down

0 comments on commit 8455523

Please sign in to comment.