Skip to content

Commit 0b5f730

Browse files
author
Vincent Landau
committed
add tests for correct number of edges, fix a docstring
1 parent 7f8743b commit 0b5f730

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/rastergraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ here include `<`, `<=`, `==`, etc. The first argument to `condition` corresponds
327327
to the source vertex, and the second argument corresponds to the destination
328328
vertex. So, if you only want to connect sources to destinations with a lower
329329
value in `raster` (e.g. in the case of developing a hydrologic flow
330-
graph based on elevation), then you would use `<` for `condition`. Defaults to
330+
graph based on elevation), then you would use `>` for `condition`. Defaults to
331331
`is_data`, which results in neighbors being connected as long as they are not
332332
NoData in `raster` (`raster.missingval`). Note that if using
333333
an inequality function (or any function where the result depends on argument

test/weightedrasterdigraphs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ A_array = Array{Float64}(undef, (3, 4, 1))
33
A_array[:,:,:] = [1, 3, 2, 0.5, 10, 8, 5, -9999, 3, 1, 2, 6]
44

55
condition_array = Array{Float64}(undef, (3, 4, 1))
6-
condition_array[:,:,:] = [1, 0.5, 5, 2, 4, 8, 5, -9999, 2, 3, 6, 7]
6+
condition_array[:,:,:] = [1, 0.5, 5, 2, 4, 8, 5, -9999, 2, 3, 6, 6]
77

88
x = X(1:4)
99
y = Y(1:3)
@@ -34,6 +34,8 @@ rasgraph = weightedrastergraph(
3434

3535
graph_edges = collect(edges(rasgraph))
3636

37+
@test length(graph_edges) == 20 # Hard coded based on A_array and condition_array above...
38+
3739
# Test that the edges are correct and have proper weights
3840
for i in 1:length(graph_edges)
3941
source_i = src(graph_edges[i])

test/weightedrastergraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ rasgraph = weightedrastergraph(weight_raster, connect_using_avg_weights = false)
3131

3232
graph_edges = collect(edges(rasgraph))
3333

34+
@test length(graph_edges) == 21 # hard coded based on A_array as defined above
35+
3436
# Test that the edges are correct and have proper weights
3537
for i in 1:length(graph_edges)
3638
source_i = src(graph_edges[i])

0 commit comments

Comments
 (0)