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

Commit 77cfe64

Browse files
committed
Refactor thin and cluster process
1 parent 772f017 commit 77cfe64

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/processes/cluster.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function randsingle(rng::Random.AbstractRNG, p::ClusterProcess, g)
7575

7676
# combine offsprings into single set
7777
points = mapreduce(vcat, offsprings) do pset
78-
isnothing(pset) ? Point{Dim,T}[] : collect(view(pset, g))
78+
isnothing(pset) ? Point{Dim,T}[] : collect(pset g)
7979
end
8080

8181
# return point pattern

src/processes/poisson.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function randsingle(rng::Random.AbstractRNG, p::PoissonProcess{<:Function}, g)
4747
pset = randsingle(rng, PoissonProcess(λmax), g)
4848

4949
# thin point pattern
50-
isnothing(pset) ? nothing : PointSet(collect(thin(pset, RandomThinning(x -> p.λ(x) / λmax))))
50+
isnothing(pset) ? nothing : thin(pset, RandomThinning(x -> p.λ(x) / λmax))
5151
end
5252

5353
function randsingle(rng::Random.AbstractRNG, p::PoissonProcess{<:AbstractVector}, d::Domain)

src/thinning/random.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ thin(p::PoissonProcess{<:Function}, t::RandomThinning{<:Real}) = PoissonProcess(
3939
function thin(pp::PointSet, t::RandomThinning{<:Real})
4040
draws = rand(Bernoulli(t.p), nelements(pp))
4141
inds = findall(isequal(1), draws)
42-
view(pp, inds)
42+
points = collect(view(pp, inds))
43+
PointSet(points)
4344
end
4445

4546
function thin(pp::PointSet, t::RandomThinning{<:Function})
@@ -50,5 +51,6 @@ function thin(pp::PointSet, t::RandomThinning{<:Function})
5051
push!(inds, j)
5152
end
5253
end
53-
view(pp, inds)
54+
points = collect(view(pp, inds))
55+
PointSet(points)
5456
end

0 commit comments

Comments
 (0)