Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Jan 31, 2025
1 parent 2098d26 commit 36e6b88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/ParticleSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,12 @@ function update_cutoff!(sys::ParticleSystem2, cutoff)
return sys
end

@testitem "update_cutoff!" begin
@testitem "update_cutoff!" setup=[AllocTest] begin
using BenchmarkTools
using StaticArrays
using CellListMap
using PDBTools
using .AllocTest: Allocs
x = rand(SVector{3,Float64}, 1000)
sys1 = ParticleSystem(xpositions=x, unitcell=[1, 1, 1], cutoff=0.1, output=0.0)
update_cutoff!(sys1, 0.2)
Expand Down Expand Up @@ -947,10 +948,11 @@ function UpdateParticleSystem!(sys::ParticleSystem2, update_lists::Bool=true)
end

# this updates must be non-allocating in the serial case
@testitem "UpdateParticleSystem!" begin
@testitem "UpdateParticleSystem!" setup=[AllocTest] begin
using BenchmarkTools
using StaticArrays
using CellListMap
using .AllocTest: Allocs
x = rand(SVector{3,Float64}, 1000)
sys = ParticleSystem(xpositions=x, unitcell=[1.0, 1.0, 1.0], cutoff=0.1, output=0.0, parallel=false)
a = @ballocated CellListMap.UpdateParticleSystem!($sys) samples = 1 evals = 1
Expand Down
24 changes: 12 additions & 12 deletions src/neighborlists.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,23 +439,23 @@ end
neighborlist!(system)
x = rand(SVector{3,Float64}, 10^3)
allocs = @ballocated update!($system, $x) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x; cutoff=0.2) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated neighborlist!($system) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)

# Non-Periodic systems
x = rand(SVector{3,Float64}, 10^3)
system = InPlaceNeighborList(x=x, cutoff=0.1, parallel=false)
neighborlist!(system)
x = rand(SVector{3,Float64}, 10^3)
allocs = @ballocated update!($system, $x) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x; cutoff=0.2) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated neighborlist!($system) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)

#
# Two sets of particles
Expand All @@ -468,11 +468,11 @@ end
x = rand(SVector{3,Float64}, 10^3)
y = rand(SVector{3,Float64}, 10^3)
allocs = @ballocated neighborlist!($system) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x, $y) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x, $y; cutoff=0.2) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)

# Non-Periodic systems
y = rand(SVector{3,Float64}, 10^3)
Expand All @@ -481,11 +481,11 @@ end
x = rand(SVector{3,Float64}, 10^3)
y = rand(SVector{3,Float64}, 10^3)
allocs = @ballocated neighborlist!($system) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x, $y) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)
allocs = @ballocated update!($system, $x, $y; cutoff=0.2) evals = 1 samples = 1
@test allocs = Allocs(0)
@test allocs == Allocs(0)

end

Expand Down

0 comments on commit 36e6b88

Please sign in to comment.