Skip to content

Commit c4aaa54

Browse files
authored
Fix AtomsBaseTesting.test_approx_eq issue (#129)
* Updates * up
1 parent d6fde5f commit c4aaa54

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/AtomsBaseTesting/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AtomsBaseTesting"
22
uuid = "ed7c10db-df7e-4efa-a7be-4f4190f7f227"
33
authors = ["JuliaMolSim community"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"

lib/AtomsBaseTesting/src/AtomsBaseTesting.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ function test_approx_eq(s::AbstractSystem, t::AbstractSystem;
7272
end
7373

7474
# Test some things on cell objects
75-
@test typeof(cell(s)) == typeof(cell(t))
75+
if cell(s) isa PeriodicCell
76+
@test maximum(map(rnorm, bounding_box(cell(s)), bounding_box(cell(t)))) < rtol
77+
end
7678
@test periodicity(cell(s)) == periodicity(cell(t))
7779
@test n_dimensions(cell(s)) == n_dimensions(cell(t))
7880

lib/AtomsBaseTesting/test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,17 @@ include("testmacros.jl")
109109
test_approx_eq(hydrogen, hydrogen)
110110
end
111111

112+
@testset "Identical systems with just different units" begin
113+
box = 10.26 / 2 * [[0, 0, 1], [1, 0, 1], [1, 1, 0]]u"bohr"
114+
box_A = [[uconvert.(u"Å", i[j]) for j in 1:3] for i in box]
115+
silicon = AtomsBase.periodic_system([:Si => ones(3)/8,
116+
:Si => -ones(3)/8],
117+
box, fractional=true)
118+
silicon_A = AtomsBase.periodic_system([:Si => ones(3)/8,
119+
:Si => -ones(3)/8],
120+
box_A, fractional=true)
121+
@testpass AtomsBaseTesting.test_approx_eq(silicon, silicon_A)
122+
end
123+
112124
# TODO More tests would be useful
113125
end

0 commit comments

Comments
 (0)