diff --git a/Project.toml b/Project.toml index 2c9eaaa..570f1a3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AtomsBase" uuid = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" authors = ["JuliaMolSim community"] -version = "0.3.4" +version = "0.3.5" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/docs/make.jl b/docs/make.jl index bdfb885..82ee498 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,7 +6,6 @@ DocMeta.setdocmeta!(AtomsBase, :DocTestSetup, :(using AtomsBase); recursive=true makedocs(; modules=[AtomsBase], authors="JuliaMolSim community", - repo="https://github.com/JuliaMolSim/AtomsBase.jl/blob/{commit}{path}#{line}", sitename="AtomsBase.jl", format=Documenter.HTML(; prettyurls=get(ENV, "CI", "false") == "true", @@ -22,7 +21,6 @@ makedocs(; "apireference.md" ], checkdocs=:exports, - strict=true, ) deploydocs(; diff --git a/src/visualize_ascii.jl b/src/visualize_ascii.jl index eb5990d..97f8263 100644 --- a/src/visualize_ascii.jl +++ b/src/visualize_ascii.jl @@ -16,11 +16,11 @@ function visualize_ascii(system::AbstractSystem{D}) where {D} cell = austrip.(reduce(hcat, bounding_box(system))) box = Vector(diag(cell)) shift = zero(box) + plot_box = D > 1 is_right_handed = det(cell) > 0 is_right_handed || return "" - plot_box = D > 1 is_orthorhombic = isdiag(cell) if !is_orthorhombic # Build an orthorhombic cell inscribing the actual unit cell @@ -34,6 +34,9 @@ function visualize_ascii(system::AbstractSystem{D}) where {D} plot_box = false end + # If one of the box coordinates is negative + any(box .≤ 0) && return "" + # Normalise positions normpos = [@. box * mod((shift + austrip(p)) / box, 1.0) for p in position(system)] diff --git a/test/printing.jl b/test/printing.jl index d3d21fa..2b5e509 100644 --- a/test/printing.jl +++ b/test/printing.jl @@ -24,15 +24,27 @@ using Test end @testset "Test ASCII representation of structures" begin - atoms = [:Si => [0.0, -0.125, 0.0], - :C => [0.125, 0.0, 0.0]] - box = [[10, 0.0, 0.0], [0.0, 5, 0.0], [0.0, 0.0, 7]]u"Å" - system = periodic_system(atoms, box; fractional=true) - println(visualize_ascii(system)) + @testset "3D standard system" begin + atoms = [:Si => [0.0, -0.125, 0.0], + :C => [0.125, 0.0, 0.0]] + box = [[10, 0.0, 0.0], [0.0, 5, 0.0], [0.0, 0.0, 7]]u"Å" + system = periodic_system(atoms, box; fractional=true) + println(visualize_ascii(system)) + end + + @testset "2D standard system" begin + atoms = [:Si => [0.0, -0.125], + :C => [0.125, 0.0]] + box = [[10, 0.0], [0.0, 5]]u"Å" + system = periodic_system(atoms, box; fractional=true) + println(visualize_ascii(system)) + end - atoms = [:Si => [0.0, -0.125], - :C => [0.125, 0.0]] - box = [[10, 0.0], [0.0, 5]]u"Å" - system = periodic_system(atoms, box; fractional=true) - println(visualize_ascii(system)) + @testset "3D with negative unit cell" begin + atoms = [:Si => [0.75, 0.75, 0.75], + :Si => [0.0, 0.0, 0.0]] + box = [[-2.73, -2.73, 0.0], [-2.73, 0.0, -2.73], [0.0, -2.73, -2.73]]u"Å" + system = periodic_system(atoms, box; fractional=true) + println(visualize_ascii(system)) + end end