Skip to content

Commit

Permalink
Fix AtomsBaseTesting.test_approx_eq issue (#129)
Browse files Browse the repository at this point in the history
* Updates

* up
  • Loading branch information
mfherbst authored Oct 31, 2024
1 parent d6fde5f commit c4aaa54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/AtomsBaseTesting/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AtomsBaseTesting"
uuid = "ed7c10db-df7e-4efa-a7be-4f4190f7f227"
authors = ["JuliaMolSim community"]
version = "0.3.0"
version = "0.3.1"

[deps]
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
Expand Down
4 changes: 3 additions & 1 deletion lib/AtomsBaseTesting/src/AtomsBaseTesting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function test_approx_eq(s::AbstractSystem, t::AbstractSystem;
end

# Test some things on cell objects
@test typeof(cell(s)) == typeof(cell(t))
if cell(s) isa PeriodicCell
@test maximum(map(rnorm, bounding_box(cell(s)), bounding_box(cell(t)))) < rtol
end
@test periodicity(cell(s)) == periodicity(cell(t))
@test n_dimensions(cell(s)) == n_dimensions(cell(t))

Expand Down
12 changes: 12 additions & 0 deletions lib/AtomsBaseTesting/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,17 @@ include("testmacros.jl")
test_approx_eq(hydrogen, hydrogen)
end

@testset "Identical systems with just different units" begin
box = 10.26 / 2 * [[0, 0, 1], [1, 0, 1], [1, 1, 0]]u"bohr"
box_A = [[uconvert.(u"Å", i[j]) for j in 1:3] for i in box]
silicon = AtomsBase.periodic_system([:Si => ones(3)/8,
:Si => -ones(3)/8],
box, fractional=true)
silicon_A = AtomsBase.periodic_system([:Si => ones(3)/8,
:Si => -ones(3)/8],
box_A, fractional=true)
@testpass AtomsBaseTesting.test_approx_eq(silicon, silicon_A)
end

# TODO More tests would be useful
end

2 comments on commit c4aaa54

@mfherbst
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir=lib/AtomsBaseTesting

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/118458

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a AtomsBaseTesting-v0.3.1 -m "<description of version>" c4aaa54b19c620eaf39694607bbedfd6ea9ea00d
git push origin AtomsBaseTesting-v0.3.1

Please sign in to comment.