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

Commit 88c6db9

Browse files
committed
Add tests for BinomialProcess
1 parent a8df0a1 commit 88c6db9

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

Project.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ GeoStatsBase = "0.7"
1313
julia = "1"
1414

1515
[extras]
16+
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
17+
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
18+
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
19+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
20+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
21+
QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020"
22+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1623
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
24+
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"
1725

1826
[targets]
19-
test = ["Test"]
27+
test = ["Pkg", "GR", "GeoStatsBase", "Random", "Test", "VisualRegressionTests", "Plots", "ImageMagick", "QuartzImageIO"]

src/processes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ abstract type PointProcess end
1515
Generate `n` realizations of spatial point process `p`
1616
inside spatial region `r`.
1717
"""
18-
Base.rand(p::PointProcess, r::AbstractRegion, n::Int=1) =
18+
Base.rand(p::PointProcess, r::AbstractRegion, n::Int) =
1919
[rand_single(p, r) for i in 1:n]
2020

21+
Base.rand(p::PointProcess, r::AbstractRegion) = rand_single(p, r)
22+
2123
#-----------------
2224
# IMPLEMENTATIONS
2325
#-----------------

test/processes.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@testset "Processes" begin
2+
@testset "Binomial" begin
3+
p = BinomialProcess(100)
4+
r = RectangleRegion((0., 1.), (1., 2.))
5+
P = rand(p, r)
6+
X = coordinates(P)
7+
@test all(0 .≤ X[1,:] .≤ 1)
8+
@test all(1 .≤ X[2,:] .≤ 2)
9+
end
10+
end

test/runtests.jl

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
using PointPatterns
2-
using Test
2+
using GeoStatsBase
3+
using Plots, VisualRegressionTests
4+
using Test, Pkg, Random
5+
6+
# workaround GR warnings
7+
ENV["GKSwstype"] = "100"
8+
9+
# environment settings
10+
islinux = Sys.islinux()
11+
istravis = "TRAVIS" keys(ENV)
12+
datadir = joinpath(@__DIR__,"data")
13+
visualtests = !istravis || (istravis && islinux)
14+
if !istravis
15+
Pkg.add("Gtk")
16+
using Gtk
17+
end
18+
19+
# list of tests
20+
testfiles = [
21+
"processes.jl"
22+
]
323

424
@testset "PointPatterns.jl" begin
5-
# Write your own tests here.
25+
for testfile in testfiles
26+
include(testfile)
27+
end
628
end

0 commit comments

Comments
 (0)