-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
888 additions
and
880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@testset "georef" begin | ||
table = Table(x=rand(3), y=[1, 2, 3], z=["a", "b", "c"]) | ||
tuple = (x=rand(3), y=[1, 2, 3], z=["a", "b", "c"]) | ||
|
||
# explicit domain types | ||
gtb = georef(table, PointSet(rand(2, 3))) | ||
@test domain(gtb) isa PointSet | ||
gtb = georef(tuple, PointSet(rand(2, 3))) | ||
@test domain(gtb) isa PointSet | ||
gtb = georef(table, CartesianGrid(3)) | ||
@test domain(gtb) isa CartesianGrid | ||
gtb = georef(tuple, CartesianGrid(3)) | ||
@test domain(gtb) isa CartesianGrid | ||
|
||
# vectors of geometries | ||
gtb = georef(table, rand(Point2, 3)) | ||
@test domain(gtb) isa PointSet | ||
gtb = georef(tuple, rand(Point2, 3)) | ||
@test domain(gtb) isa PointSet | ||
gtb = georef(table, collect(CartesianGrid(3))) | ||
@test domain(gtb) isa GeometrySet | ||
gtb = georef(tuple, collect(CartesianGrid(3))) | ||
@test domain(gtb) isa GeometrySet | ||
|
||
# coordinates of point set | ||
gtb = georef(table, rand(2, 3)) | ||
@test domain(gtb) isa PointSet | ||
gtb = georef(tuple, rand(2, 3)) | ||
@test domain(gtb) isa PointSet | ||
|
||
# coordinates names in table | ||
gtb = georef(table, (:x, :y)) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(tuple, (:x, :y)) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(table, [:x, :y]) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(tuple, [:x, :y]) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(table, ("x", "y")) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(tuple, ("x", "y")) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(table, ["x", "y"]) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
gtb = georef(tuple, ["x", "y"]) | ||
@test domain(gtb) isa PointSet | ||
@test propertynames(gtb) == [:z, :geometry] | ||
|
||
# grid data | ||
tuple1D = (x=rand(10), y=rand(10)) | ||
gtb = georef(tuple1D) | ||
@test domain(gtb) == CartesianGrid(10) | ||
tuple2D = (x=rand(10, 10), y=rand(10, 10)) | ||
gtb = georef(tuple2D) | ||
@test domain(gtb) == CartesianGrid(10, 10) | ||
tuple3D = (x=rand(10, 10, 10), y=rand(10, 10, 10)) | ||
gtb = georef(tuple3D) | ||
@test domain(gtb) == CartesianGrid(10, 10, 10) | ||
# different types | ||
tuple1D = (x=[rand(9); missing], y=rand(10)) | ||
gtb = georef(tuple1D) | ||
@test domain(gtb) == CartesianGrid(10) | ||
tuple2D = (x=rand(10, 10), y=BitArray(rand(Bool, 10, 10))) | ||
gtb = georef(tuple2D) | ||
@test domain(gtb) == CartesianGrid(10, 10) | ||
# throws: different sizes | ||
tuple2D = (x=rand(3, 3), y=rand(5, 5)) | ||
@test_throws AssertionError georef(tuple2D) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@testset "indices" begin | ||
# ------------- | ||
# PARTITIONING | ||
# ------------- | ||
t = georef((a=rand(100), b=rand(100)), CartesianGrid(10, 10)) | ||
for method in [ | ||
UniformPartition(2), | ||
FractionPartition(0.5), | ||
BlockPartition(2), | ||
BallPartition(2), | ||
BisectPointPartition(Vec(1, 1), Point(5, 5)), | ||
BisectFractionPartition(Vec(1, 1), 0.5), | ||
PlanePartition(Vec(1, 1)), | ||
DirectionPartition(Vec(1, 1)), | ||
PredicatePartition((i, j) -> iseven(i + j)), | ||
SpatialPredicatePartition((x, y) -> norm(x + y) < 5), | ||
ProductPartition(UniformPartition(2), UniformPartition(2)), | ||
HierarchicalPartition(UniformPartition(2), UniformPartition(2)) | ||
] | ||
Π = partition(t, method) | ||
inds = reduce(vcat, indices(Π)) | ||
@test sort(inds) == 1:100 | ||
end | ||
|
||
# --------- | ||
# SAMPLING | ||
# --------- | ||
t = georef((z=rand(50, 50),)) | ||
s = sample(t, UniformSampling(100)) | ||
@test nrow(s) == 100 | ||
|
||
# -------- | ||
# SORTING | ||
# -------- | ||
# TODO | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
@testset "No attributes" begin | ||
pset = PointSet((0, 0), (1, 1), (2, 2)) | ||
gtb = GeoTable(pset) | ||
@test ncol(gtb) == 1 | ||
|
||
# GeoTableRows | ||
rows = Tables.rows(gtb) | ||
sch = Tables.schema(rows) | ||
@test sch.names == (:geometry,) | ||
@test sch.types == (Point2,) | ||
row, state = iterate(rows) | ||
@test Tables.columnnames(row) == (:geometry,) | ||
@test Tables.getcolumn(row, :geometry) == pset[1] | ||
row, state = iterate(rows, state) | ||
@test Tables.columnnames(row) == (:geometry,) | ||
@test Tables.getcolumn(row, :geometry) == pset[2] | ||
row, state = iterate(rows, state) | ||
@test Tables.columnnames(row) == (:geometry,) | ||
@test Tables.getcolumn(row, :geometry) == pset[3] | ||
@test isnothing(iterate(rows, state)) | ||
|
||
# dataframe interface | ||
@test propertynames(gtb) == [:geometry] | ||
@test gtb.geometry == pset | ||
@test gtb[1:2, [:geometry]].geometry == view(pset, 1:2) | ||
@test gtb[1, [:geometry]].geometry == pset[1] | ||
@test gtb[1, :].geometry == pset[1] | ||
@test gtb[:, [:geometry]] == gtb | ||
ngtb = georef((; x=rand(3)), pset) | ||
hgtb = hcat(gtb, ngtb) | ||
@test propertynames(hgtb) == [:x, :geometry] | ||
@test hgtb.x == ngtb.x | ||
@test hgtb.geometry == pset | ||
npset = PointSet((4, 4), (5, 5), (6, 6)) | ||
ngtb = GeoTable(npset) | ||
vgtb = vcat(gtb, ngtb) | ||
@test propertynames(vgtb) == [:geometry] | ||
@test vgtb.geometry == PointSet([collect(pset); collect(npset)]) | ||
|
||
# viewing | ||
v = view(gtb, [1, 3]) | ||
@test isnothing(values(v)) | ||
@test v.geometry == view(pset, [1, 3]) | ||
|
||
# throws | ||
@test_throws ErrorException gtb.test | ||
@test_throws AssertionError gtb[[1, 3], [:test]] | ||
@test_throws AssertionError gtb[2, [:test]] | ||
@test_throws AssertionError gtb[:, [:test]] | ||
@test_throws AssertionError gtb[:, r"test"] | ||
ngtb = georef((; x=rand(3)), npset) | ||
@test_throws ArgumentError vcat(gtb, ngtb) | ||
end |
Oops, something went wrong.