-
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
11 changed files
with
235 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: geoGraph | ||
Type: Package | ||
Title: Walking through the geographic space using graphs | ||
Version: 1.1.1.9001 | ||
Version: 1.1.1.9002 | ||
Authors@R: c( | ||
person("Thibaut", "Jombart", role = "aut"), | ||
person("Andrea", "Manica", email = "[email protected]", role = c("aut", "cre"))) | ||
|
@@ -23,14 +23,17 @@ Depends: | |
methods, | ||
graph | ||
Imports: | ||
fields, | ||
RBGL, | ||
sp | ||
fields, | ||
RBGL, | ||
rnaturalearth, | ||
rnaturalearthdata, | ||
sp, | ||
sf, | ||
magrittr | ||
Suggests: | ||
testthat, | ||
knitr, | ||
rmarkdown, | ||
sf | ||
rmarkdown | ||
RoxygenNote: 7.2.3 | ||
Collate: | ||
'classes.R' | ||
|
@@ -55,5 +58,6 @@ Collate: | |
'rebuild.R' | ||
'setCosts.R' | ||
'setDistCosts.R' | ||
'utils-pipe.R' | ||
'zoom.R' | ||
'zzz.R' |
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
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
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,14 @@ | ||
#' Pipe operator | ||
#' | ||
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. | ||
#' | ||
#' @name %>% | ||
#' @rdname pipe | ||
#' @keywords internal | ||
#' @export | ||
#' @importFrom magrittr %>% | ||
#' @usage lhs \%>\% rhs | ||
#' @param lhs A value or the magrittr placeholder. | ||
#' @param rhs A function call using the magrittr semantics. | ||
#' @return The result of calling `rhs(lhs)`. | ||
NULL |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
library("geoGraph") | ||
context("Test classes") | ||
|
||
test_that("Empty constructors work", { | ||
skip_on_cran() | ||
x <- new("gGraph") | ||
expect_true(inherits(x,"gGraph")) | ||
y <- new("gData") | ||
expect_is(x, "gGraph") | ||
expect_is(y, "gData") | ||
expect_true(inherits(y,"gData")) | ||
}) | ||
|
||
test_that("Contructors fails with invalid coordinates",{ | ||
NACoords <- data.frame(long = c(-24, NA), lat = c(31,55)) | ||
#Create gGraph with NA's | ||
expect_error(new("gGraph", coords = NACoords), | ||
"Argument coords includes NAs") | ||
|
||
}) | ||
|
||
test_that("Contructors fails with invalid matrix dimensions",{ | ||
extra_coords <- data.frame(long = c(-24, 37), lat = c(31,55), x = c(31,31)) | ||
#Create gGraph with three columns | ||
expect_error(new("gGraph", coords = extra_coords), | ||
"Argument coords must include") | ||
|
||
}) | ||
|
||
test_that("Contructors fails with invalid non-numeric matrix",{ | ||
non_num_coords <- data.frame(long = c("lon1", 37), lat = c(31,55)) | ||
#Create gGraph with non numeric elements | ||
expect_error(new("gGraph", coords = non_num_coords), | ||
"Argument coords has to be numeric") | ||
|
||
}) | ||
|
||
|
||
|
||
test_that("Constructor accounts for different column names" , { | ||
columnheading_names <- | ||
data.frame(longitude = c(31, 55), Latitude = c(-24, 37)) | ||
columnheading_names <- new("gGraph", coords = columnheading_names) | ||
new_columnheading_names <- | ||
data.frame(lon = c(31, 55), lat = c(-24, 37)) | ||
new_columnheading_names <- | ||
new("gGraph", coords = new_columnheading_names) | ||
expect_identical(columnheading_names, | ||
new_columnheading_names) | ||
|
||
}) | ||
|
||
test_that("Constructor reverses coord column order" , { | ||
column_heading <- data.frame(lat = c(-24, 37), lon = c(31,55)) | ||
#Create Ggraph with lat/lon headings | ||
correct_heading <- new("gGraph", coords = column_heading) | ||
column_heading <- data.frame(lon = c(31,55), lat = c(-24, 37)) | ||
#Create Ggraph with lon/lat headings | ||
swapped_heading <- new("gGraph", coords = column_heading) | ||
expect_identical(correct_heading, swapped_heading) | ||
}) | ||
|
||
test_that("we give message when columns are not recognised",{ | ||
column_heading <- data.frame(lon= c(31,55), lat = c(-24, 37)) | ||
#Create Ggraph with lat/lon headings | ||
correct_heading <- new("gGraph", coords = column_heading) | ||
column_heading <- data.frame(blah= c(31,55), lat = c(-24, 37)) | ||
#Create Ggraph with lon/lat headings | ||
expect_message(unrecognised_heading <- new("gGraph", coords = column_heading), | ||
"The coordinate column names are not part of the standardised list") | ||
expect_identical(correct_heading, unrecognised_heading) | ||
} | ||
|
||
|
||
) |
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,8 @@ | ||
test_that("extractFromLayer assigns points correctly", | ||
{ | ||
# create a matrix of locations including two continents and the sea | ||
myCoords <- data.frame(long = c(-24, 71.5, -46.5), lat = c(31, 30,-23.5)) | ||
# assign to continents | ||
continents <- extractFromLayer(myCoords, layer = worldshape, attr = "CONTINENT") | ||
expect_identical(as.character(continents$CONTINENT), c(NA,"Asia","South America")) | ||
}) |
Oops, something went wrong.