Skip to content

Commit 327e34e

Browse files
authored
Merge pull request #31 from JuliaGeometry/GeometryBasics
Geometry basics
2 parents 72009e2 + c10f890 commit 327e34e

File tree

6 files changed

+33
-31
lines changed

6 files changed

+33
-31
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- '1.5'
18+
- '1.6'
19+
- '1.7'
1920
os:
2021
- ubuntu-latest
2122
arch:

Project.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "VoronoiCells"
22
uuid = "e3e34ffb-84e9-5012-9490-92c94d0c60a4"
33
authors = ["Robert Dahl Jacobsen <[email protected]>"]
4-
version = "0.2.2"
4+
version = "0.3.0"
55

66
[deps]
77
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
@@ -10,10 +10,10 @@ VoronoiDelaunay = "72f80fcb-8c52-57d9-aff0-40c1a3526986"
1010

1111
[compat]
1212
Deldir = "1.3"
13-
GeometryBasics = "0.3.5"
14-
RecipesBase = "1.1"
15-
VoronoiDelaunay = "0.4.0"
16-
julia = "1.5"
13+
GeometryBasics = "0.4"
14+
RecipesBase = "1.2"
15+
VoronoiDelaunay = "0.4"
16+
julia = "^1.5"
1717

1818
[extras]
1919
Deldir = "64db5801-a3ae-51a7-b7d2-a0a5f0813e47"

README.jmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ using Random
3434
pyplot()
3535
```
3636

37-
First make a vector of points and a rectangle that contains the points:
37+
First make a vector of points and a rectangle that contains the points (this README was first made when `MersenneTwister` was the default random number generator; I stick with this to make the results reproducible):
3838

3939
```julia
40-
Random.seed!(1337)
40+
rng = Random.MersenneTwister(1337)
4141
rect = Rectangle(Point2(0, 0), Point2(1, 1))
42-
points = [Point2(rand(), rand()) for _ in 1:10]
42+
points = [Point2(rand(rng), rand(rng)) for _ in 1:10]
4343
```
4444

4545
The main function of *VoronoiCells* is `voronoicells` that computes the cell of each generator point.

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ using Random
3939
First make a vector of points and a rectangle that contains the points:
4040

4141
```julia
42-
Random.seed!(1337)
42+
rng = Random.MersenneTwister(1337)
4343
rect = Rectangle(Point2(0, 0), Point2(1, 1))
44-
points = [Point2(rand(), rand()) for _ in 1:10]
44+
points = [Point2(rand(rng), rand(rng)) for _ in 1:10]
4545
```
4646

4747
```
48-
10-element Array{GeometryBasics.Point{2,Float64},1}:
48+
10-element Vector{Point2{Float64}}:
4949
[0.22658190197881312, 0.5046291972412908]
5050
[0.9333724636943255, 0.5221721267193593]
5151
[0.5052080505550971, 0.09978246027514359]
@@ -80,10 +80,10 @@ tess.Cells[1]
8080
```
8181

8282
```
83-
5-element Array{GeometryBasics.Point{2,Float64},1}:
83+
5-element Vector{Point2{Float64}}:
8484
[0.0, 0.5006658246439761]
8585
[0.0, 0.2909467571782577]
86-
[0.22132548929287787, 0.24066681274894675]
86+
[0.2213254892928772, 0.24066681274894675]
8787
[0.3041376415938776, 0.3046324682958502]
8888
[0.30224294454977085, 0.7530369438246255]
8989
```
@@ -112,17 +112,17 @@ voronoiarea(tess)
112112
```
113113

114114
```
115-
10-element Array{Float64,1}:
115+
10-element Vector{Float64}:
116116
0.10905486942527855
117117
0.07490860886924389
118118
0.05461848195251296
119-
0.1295227626242153
119+
0.12952276262421533
120120
0.0943320987129441
121-
0.07231514118679619
122-
0.14583818637774296
121+
0.07231514118679612
122+
0.14583818637774282
123123
0.06295556177551635
124-
0.17457664323539532
125-
0.08187764584035444
124+
0.1745766432353954
125+
0.08187764584035451
126126
```
127127

128128

test/Cells.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ using Test
66

77
@testset "Cells" begin
88
@testset "PointCollection from GeometryBasics" begin
9-
Random.seed!(2)
10-
points = [Point2(rand(), rand()) for _ in 1:5]
9+
rng = Random.MersenneTwister(2)
10+
points = [Point2(rand(rng), rand(rng)) for _ in 1:5]
1111
rect = Rectangle(Point2(0, 0), Point2(1, 1))
1212

1313
pc = VoronoiCells.PointCollection(points, rect)
@@ -16,8 +16,8 @@ using Test
1616
end
1717

1818
@testset "PointCollection from VoronoiDelaunay" begin
19-
Random.seed!(2)
20-
points = [VoronoiDelaunay.Point2D(1 + rand(), 1 + rand()) for _ in 1:5]
19+
rng = Random.MersenneTwister(2)
20+
points = [VoronoiDelaunay.Point2D(1 + rand(rng), 1 + rand(rng)) for _ in 1:5]
2121
rect = Rectangle(VoronoiDelaunay.Point2D(1.1, 1.1), VoronoiDelaunay.Point2D(1.9, 1.9))
2222

2323
pc = VoronoiCells.PointCollection(points, rect)
@@ -26,8 +26,8 @@ using Test
2626
end
2727

2828
@testset "Error making PointCollection with mix of VoronoiDelaunay and GeometryBasics" begin
29-
Random.seed!(2)
30-
points = [VoronoiDelaunay.Point2D(1 + rand(), 1 + rand()) for _ in 1:5]
29+
rng = Random.MersenneTwister(2)
30+
points = [VoronoiDelaunay.Point2D(1 + rand(rng), 1 + rand(rng)) for _ in 1:5]
3131
rect = Rectangle(Point2(1, 1), Point2(2, 2))
3232

3333
@test_throws MethodError VoronoiCells.PointCollection(points, rect)
@@ -68,8 +68,8 @@ using Test
6868
end
6969

7070
@testset "Random point set" begin
71-
Random.seed!(1)
72-
points = [Point2(rand(), rand()) for _ in 1:5]
71+
rng = Random.MersenneTwister(1)
72+
points = [Point2(rand(rng), rand(rng)) for _ in 1:5]
7373

7474
rect = Rectangle(Point2(0, 0), Point2(1, 1))
7575

test/Rectangle.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using Test
1616
@test isa(rect, Rectangle{Point{2, Float64}})
1717
end
1818

19-
@testset "Construct with with VoronoiDelaunay points" begin
19+
@testset "Construct with VoronoiDelaunay points" begin
2020
rect = Rectangle(VoronoiDelaunay.Point2D(1.1, 1.1), VoronoiDelaunay.Point2D(1.6, 1.7))
2121
@test isa(rect, Rectangle{VoronoiDelaunay.Point2D})
2222
end
@@ -70,12 +70,13 @@ using Test
7070
@test_throws ErrorException VoronoiCells.map_rectangle(points, from_rect, to_rect)
7171
end
7272

73+
7374
@testset "Find points nearest to each rectangle corner" begin
7475
rect = Rectangle(GeometryBasics.Point2(0, 0), GeometryBasics.Point2(1, 1))
7576

7677
@testset "Unique nearest neighbors" begin
77-
Random.seed!(1)
78-
points = [Point2(rand(), rand()) for _ in 1:5]
78+
rng = Random.MersenneTwister(1)
79+
points = [Point2(rand(rng), rand(rng)) for _ in 1:5]
7980

8081
corner_neighbors = VoronoiCells.corner_nearest_neighbor(points, rect)
8182

0 commit comments

Comments
 (0)