Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 25b9dde

Browse files
committed
Refatoring
1 parent cc16775 commit 25b9dde

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/processes/poisson.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:Real}, g, ::Di
5353
n = rand(rng, Poisson* V))
5454

5555
if iszero(n)
56-
# PointSet{embeddim(g), coordtype(g)}([])
5756
nothing
5857
else
5958
# simulate homogeneous process
@@ -76,14 +75,8 @@ function rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:Function}, g,
7675
thin(pp, RandomThinning(x -> p.λ(x) / algo.λmax))
7776
end
7877

79-
function rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:Function}, d::Domain, algo::DiscretizedSampling)
80-
# compute intensity on centroids
81-
c = centroid.(d)
82-
λvec = p.λ.(c)
83-
84-
# simulate inhomogeneous process
85-
rand_single(rng, PoissonProcess(λvec), d, algo)
86-
end
78+
rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:Function}, d::Domain, algo::DiscretizedSampling) =
79+
rand_single(rng, PoissonProcess(p.λ.(centroid.(d))), d, algo)
8780

8881
function rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:AbstractVector}, d::Domain, algo::DiscretizedSampling)
8982
# simulate number of points

test/processes.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
end
3434

3535
@testset "Poisson" begin
36+
# helper function
37+
λ(s::Point2) = sum(coordinates(s) .^ 2)
38+
3639
# homogeneous
3740
p = PoissonProcess(10.0)
3841
for g in [seg, tri, quad, box, ball, poly, grid, mesh]
@@ -41,7 +44,6 @@
4144
end
4245

4346
# inhomogeneous with intensity function
44-
λ(s::Point2) = sum(coordinates(s) .^ 2)
4547
p = PoissonProcess(λ)
4648
for g in [seg, tri, quad, box, ball, poly, grid, mesh]
4749
# default thinnedsampling
@@ -58,7 +60,6 @@
5860

5961
# inhomogeneous with piecewise constant intensity
6062
for g in [grid, mesh]
61-
λ(s::Point2) = sum(coordinates(s) .^ 2)
6263
λvec = λ.(centroid.(g))
6364
p = PoissonProcess(λvec)
6465
# discretizedsampling by default

0 commit comments

Comments
 (0)