Skip to content

Commit

Permalink
remove dependency on reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotmcintire committed Jun 20, 2018
1 parent 8af5cdb commit c38fc90
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 66 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Expand Up @@ -41,7 +41,6 @@ Suggests:
fastshp,
hunspell,
knitr,
reproducible,
rmarkdown,
testthat (>= 1.0.2)
Remotes:
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Expand Up @@ -2,10 +2,11 @@ Known issues: https://github.com/PredictiveEcology/quickPlot/issues

version 0.1.4
=============
* much faster for `SpatialPolygons`
* `clickExtent` now more interactive with new examples
* remove dependency on `reproducible`
* `SpatialPolygons` get a fill colour by default if not passed in by user
* fix bug related to plotting with NAs (#14, @CeresBarros)
* much faster for `SpatialPolygons`
* bug fixes
* new options("quickPlot.maxNumPolygons"), used for plotting of large `SpatialPolygons` objects

Expand Down
59 changes: 26 additions & 33 deletions tests/testthat/test-Plot.R
@@ -1,14 +1,14 @@
test_that("Plot 1 is not error-free", {
skip_if_not_installed("reproducible")
skip_if_not_installed("fastshp")

library(igraph)
library(sp)
library(raster)
library(reproducible)
library(fastshp)

tmpdir <- file.path(tempdir(), "test_Plot1") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot1")
dir.create(tmpdir)

cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -175,16 +175,16 @@ test_that("Plot 1 is not error-free", {
})

test_that("Unit tests for image content is not error-free", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(visualTest); #on.exit(detach("package:visualTest"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot_imageContent") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot_imageContent")
dir.create(tmpdir)

cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -264,16 +264,16 @@ test_that("Unit tests for image content is not error-free", {
})

test_that("Unit tests for plotting colors", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(visualTest); #on.exit(detach("package:visualTest"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot_colors") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot_colors")
dir.create(tmpdir)

cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -359,16 +359,15 @@ test_that("Unit tests for plotting colors", {
})

test_that("Unit tests for internal functions in Plot", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(visualTest); #on.exit(detach("package:visualTest"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot_internal") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot_internal")
dir.create(tmpdir)
cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -439,16 +438,16 @@ test_that("Unit tests for internal functions in Plot", {
})

test_that("Plot 2 is not error-free", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()

library(raster)
library(visualTest)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot2") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot2")
dir.create(tmpdir)

cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -613,14 +612,13 @@ test_that("Plot 2 is not error-free", {
test_that("setColors is not error-free", {
skip("Apparently color palettes are not universal")

skip_if_not_installed("reproducible")

skip_on_travis()

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_setColors") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_setColors")
dir.create(tmpdir)
cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -674,7 +672,6 @@ test_that("setColors is not error-free", {
})

test_that("Plot with base is not error-free", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()
Expand All @@ -683,17 +680,16 @@ test_that("Plot with base is not error-free", {
library(raster)
library(ggplot2)
library(igraph)
library(reproducible)

tmpdir <- file.path(tempdir(), "test_Plot1") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot1")
dir.create(tmpdir)
cwd <- getwd()
setwd(tmpdir)

on.exit({
#detach("package:igraph")
#detach("package:ggplot2")
#detach("package:raster")
#detach("package:reproducible")
#detach("package:visualTest")
setwd(cwd)
#if (length(dev.list()) > 0) dev.off()
Expand Down Expand Up @@ -886,14 +882,13 @@ test_that("Plot messages and warnings and errors", {
})

test_that("rePlot doesn't work", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(visualTest); #on.exit(detach("package:visualTest"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot1") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot1")
dir.create(tmpdir)
cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -924,12 +919,11 @@ test_that("rePlot doesn't work", {
})

test_that("Plot - going through package coverage", {
skip_if_not_installed("reproducible")

library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot1") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot1")
dir.create(tmpdir)
cwd <- getwd()
setwd(tmpdir)

Expand All @@ -951,17 +945,17 @@ test_that("Plot - going through package coverage", {
})

test_that("Plot lists", {
skip_if_not_installed("reproducible")
skip_if_not_installed("visualTest")

skip_on_travis()

library(ggplot2); #on.exit(detach("package:ggplot2"), add = TRUE)
library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(visualTest); #on.exit(detach("package:visualTest"), add = TRUE)
library(reproducible); #on.exit(detach("package:reproducible"), add = TRUE)

tmpdir <- file.path(tempdir(), "test_Plot1") %>% checkPath(create = TRUE)
tmpdir <- file.path(tempdir(), "test_Plot1")
dir.create(tmpdir)

cwd <- getwd()
setwd(tmpdir)

Expand Down Expand Up @@ -1063,10 +1057,9 @@ test_that("Plot functions NOT in quickPlot, i.e. redefining Plot", {
expect_silent(Plot(raster(matrix(1:100, 10, 10))))
})

test_that("LARGE polygons plot fast enoug", {
test_that("LARGE polygons plot fast enough", {
skip("This is for manual testing only")
library(raster); #on.exit(detach("package:raster"), add = TRUE)
library(reproducible)
a <- Cache(shapefile,
"C:\\Eliot\\data\\Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010\\EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shp")

Expand Down
42 changes: 11 additions & 31 deletions tests/testthat/test-clickExtent.R
Expand Up @@ -14,37 +14,17 @@ test_that("clickExtent works", {

Plot(shpEcozone)


# crop_raster_gdal=function(srcfile, dstfile,shapefile) {
# require(gdalUtils)
# gdalwarp(srcfile=srcfile, dstfile=dstfile,cutline=shapefile, dstalpha=T,of = "GTiff", crop_to_cutline=T, overwrite=T)
#
# }
# 1st error -- click just outside of polygon
#clickExtent()

library(reproducible)
cacheRepo <- file.path(dirname(tempdir()), "reproducibleCache")

cacheRepo <- file.path("c:/Eliot/data",
"Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010")
checkPath(cacheRepo, create = TRUE)
b <- Cache(reproducible::prepInputs, cacheRepo = cacheRepo,
destinationPath = dirname(cacheRepo),
alsoExtract = c("EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.dbf",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.prj",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.sbn",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.sbx",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shp",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shp.xml",
"EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shx"),
archive = "Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010.zip",
showSimilar = TRUE, #cacheId = "74b33a4fb9ba7b537c017e8d0ec3e6e6",
targetFile = "EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shp",
url = "http://www.ec.gc.ca/data_donnees/STB-DGST/003/Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010.zip")


dev(); clearPlot(); Plot(b); clickExtent()
cacheRepo <- file.path(dirname(tempdir()), "testClickExtent")
dir.create(cacheRepo)
theFile <- "Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010.zip"
b <- download.file(destfile = theFile,
url = "http://www.ec.gc.ca/data_donnees/STB-DGST/003/Boreal-ecosystem-anthropogenic-disturbance-vector-data-2008-2010.zip")
unzip(zipfile = theFile, exdir = dirname(tempdir()))
bb <- raster::shapefile(file.path(dirname(tempdir()), "EC_borealdisturbance_polygonal_2008_2010_FINAL_ALBERS.shp"))

dev(); clearPlot();
Plot(bb);
for (i in 1:5) clickExtent()


})

0 comments on commit c38fc90

Please sign in to comment.