Skip to content

Commit

Permalink
add tests for construction with abstract vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Sep 14, 2023
1 parent de9771b commit 3c82e7f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/PeriodicSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,23 @@ end
sys = PeriodicSystem(xpositions=x, ypositions=y, unitcell=[1.0, 1.0, 1.0], cutoff=0.1, output=0.0, parallel=false)
a = @ballocated PeriodicSystems.UpdatePeriodicSystem!($sys) samples = 1 evals = 1
@test a == 0

# Test construction with more general abstract vectors
x = @view(x[1:500])
sys = PeriodicSystem(xpositions=x, unitcell=[1.0, 1.0, 1.0], cutoff=0.1, output=0.0, parallel=false)
a = @ballocated PeriodicSystems.UpdatePeriodicSystem!($sys) samples = 1 evals = 1
@test a == 0
y = @view(y[1:500])
sys = PeriodicSystem(xpositions=x, ypositions=y, unitcell=[1.0, 1.0, 1.0], cutoff=0.1, output=0.0, parallel=false)
a = @ballocated PeriodicSystems.UpdatePeriodicSystem!($sys) samples = 1 evals = 1
@test a == 0

x = rand(3,500)
xr = reinterpret(reshape, SVector{3,Float64}, x)
sys = PeriodicSystem(xpositions=xr, unitcell=[1.0, 1.0, 1.0], cutoff=0.1, output=0.0, parallel=false)
a = @ballocated PeriodicSystems.UpdatePeriodicSystem!($sys) samples = 1 evals = 1
@test a == 0

end

"""
Expand Down

0 comments on commit 3c82e7f

Please sign in to comment.