Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splitRaster default to memory #47

Merged
merged 4 commits into from Jul 5, 2018

Conversation

Projects
None yet
4 participants
@ianmseddy
Copy link
Contributor

ianmseddy commented Jun 29, 2018

changed behavior of splitRaster path argument so does not write to disk if path = NA

@eliotmcintire

This comment has been minimized.

Copy link
Contributor

eliotmcintire commented Jun 30, 2018

from Travis: You need to give a default value to path, if you are going to use it in a function.

  Loading required package: SpaDES.tools
  ── 1. Error: splitRaster and mergeRaster work on small in-memory rasters (@test-
  argument "path" is missing, with no default
  1: splitRaster(r, nx, ny, c(3L, 4L)) at testthat/test-splitRaster.R:84
  2: splitRaster(r, nx, ny, c(3L, 4L))
@achubaty

This comment has been minimized.

Copy link
Contributor

achubaty commented Jun 30, 2018

Based on your changes, the default path value should be NA. Alternatively you could use NULL and check for for is.null instead of is.na.

@ianmseddy

This comment has been minimized.

Copy link
Contributor Author

ianmseddy commented Jul 3, 2018

Okay, I think I fixed that. Some of the tests were failing too because writeRaster now apparently accepts "INT" and "FLT" as raster datatypes.

@@ -22,7 +22,7 @@ test_that("splitRaster and mergeRaster work on small in-memory rasters", {
extent(r) <- extent(xmin(r) - 30, xmax(r) - 30, ymin(r) - 20, ymax(r) - 20)

# no buffer
y0 <- splitRaster(r, nx, ny)
y0 <- splitRaster(r, nx, ny, path = file.path(getwd(), "red"))

This comment has been minimized.

@achubaty

achubaty Jul 4, 2018

Contributor

make sure this is a temp location

This comment has been minimized.

@ianmseddy

ianmseddy Jul 4, 2018

Author Contributor

The working directory is set to the temp directory on line 7, just before this. Do you want me to call the temp drive directly in the path argument of line 25?

This comment has been minimized.

@achubaty

achubaty Jul 4, 2018

Contributor

yes, easier to keep track of what's going on later if the tempdir used directly

@lintr-bot

This comment has been minimized.

Copy link

lintr-bot commented Jul 4, 2018

inst/examples/example_distanceFromEachPoint.R:37:2: style: Commented code should be removed.

#beginCluster(3) # can do parallel
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

inst/examples/example_distanceFromEachPoint.R:40:2: style: Commented code should be removed.

#endCluster() # if beginCluster was run
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:82:9: style: Do not place spaces around code in parentheses or square brackets.

if ( method != "RMexp") {
        ^

R/initialize.R:237:3: style: Variable or function name should be lowerCamelCase.

X <- c(jitter(sort(rbeta(nPoints, betaPar, betaPar) * (maxX - minX) + minX)),
  ^

R/initialize.R:239:3: style: Variable or function name should be lowerCamelCase.

Y <- c(jitter(sort(rbeta(nPoints / 2, betaPar, betaPar) * (maxY - meanY) + meanY)),
  ^

R/initialize.R:243:3: style: Variable or function name should be lowerCamelCase.

Sr1 <- Polygon(cbind(X + xAdd, Y + yAdd))
  ^~~

R/initialize.R:244:3: style: Variable or function name should be lowerCamelCase.

Srs1 <- Polygons(list(Sr1), "s1")
  ^~~~

R/initialize.R:341:3: style: Commented code should be removed.

# ### INCORPORATE RELEVANT PARTS OF THIS OLD INIT FUNCTION INTO INITCOORDS()
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:346:3: style: Commented code should be removed.

# #'                      (currently only \code{RasterLayer} or
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:347:3: style: Commented code should be removed.

# #'                      \code{SpatialPolygonsDataFrame}) accepted.
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:357:7: style: Commented code should be removed.

#     ext <- extent(agentlocation)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:359:9: style: Commented code should be removed.

#       #            nonNAs <- !is.na(getvalue(probinit))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:360:9: style: Commented code should be removed.

#       nonNAs <- !is.na(getValues(probinit))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:361:9: style: Commented code should be removed.

#       wh.nonNAs <- which(nonNAs)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:362:9: style: Commented code should be removed.

#       #            ProbInit.v <- cumsum(getvalue(probinit)[nonNAs])
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:363:9: style: Commented code should be removed.

#       ProbInit.v <- cumsum(getValues(probinit)[nonNAs])
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:365:11: style: Commented code should be removed.

#         ran <- runif(numagents,0,1)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:366:11: style: Commented code should be removed.

#         fI <- findInterval(ran, ProbInit.v)+1
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:367:11: style: Commented code should be removed.

#         fI2 <- wh.nonNAs[fI]
          ^~~~~~~~~~~~~~~~~~~~

R/initialize.R:368:11: style: Commented code should be removed.

#         last.ran <- runif(numagents,0,1)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:369:11: style: Commented code should be removed.

#         last.fI <- findInterval(last.ran, ProbInit.v)+1
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:370:11: style: Commented code should be removed.

#         last.fI2 <- wh.nonNAs[last.fI]
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:372:11: style: Commented code should be removed.

#         #                va <- getvalue(probinit)[nonNAs]
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:373:11: style: Commented code should be removed.

#         va <- getValues(probinit)[nonNAs]
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:374:11: style: Commented code should be removed.

#         ran <- runif(length(va), 0, 1)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:375:11: style: Commented code should be removed.

#         fI2 <- wh.nonNAs[ran<va]
          ^~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:377:11: style: Commented code should be removed.

#         last.ran <- runif(length(fI2), 0, 1)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:378:11: style: Commented code should be removed.

#         last.fI <- findInterval(last.ran, ProbInit.v) + 1
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:379:11: style: Commented code should be removed.

#         last.fI2 <- wh.nonNAs[last.fI]
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:381:11: style: Commented code should be removed.

#         #                last.ran <- runif(length(fI2),0,1)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:382:11: style: Commented code should be removed.

#         #                last.fI2 <- wh.nonNAs[last.ran<va]
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:385:11: style: Commented code should be removed.

#         position <- xyFromCell(agentlocation,fI2,spatial = TRUE)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:387:11: style: Commented code should be removed.

#         position <- coordinates(agentlocation)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:389:11: style: Commented code should be removed.

#         stop("need raster layer or Spatial Points object")
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:391:9: style: Commented code should be removed.

#       numagents <- length(position)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:399:13: style: Commented code should be removed.

#           colnames(xy) = c("x", "y")
            ^~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:400:13: style: Commented code should be removed.

#           position <- SpatialPoints(xy)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:401:13: style: Commented code should be removed.

#           position <- SpatialPoints(sampleRandom(agentlocation, numagents, xy = TRUE, sp = TRUE))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:403:13: style: Commented code should be removed.

#           sam <- sample(1:length(agentlocation),numagents)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:404:13: style: Commented code should be removed.

#           position <- SpatialPoints(agentlocation[sam,])
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:406:13: style: Commented code should be removed.

#           stop("need raster layer or Spatial Points object")
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:413:13: style: Commented code should be removed.

#           position <- SpatialPoints(agentlocation)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:415:13: style: Commented code should be removed.

#           stop("need raster layer or Spatial Points object")
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:417:11: style: Commented code should be removed.

#         numagents <- length(position)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:425:11: style: Commented code should be removed.

#         numagents <- length(position)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:429:7: style: Commented code should be removed.

#     stop("Need to provide agentlocation, which can be a map layer")
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:431:5: style: Commented code should be removed.

#   heading1 <- runif(numagents, 0, 360)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:432:5: style: Commented code should be removed.

#   distance <- runif(numagents, 0.1, 10)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:434:5: style: Commented code should be removed.

#   .Object@ID <- as.character(1:numagents)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:435:5: style: Commented code should be removed.

#   .Object@spatial <- position
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:436:5: style: Commented code should be removed.

#   .Object@heading <- heading1
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:437:5: style: Commented code should be removed.

#   .Object@distance <- distance
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/initialize.R:439:5: style: Commented code should be removed.

#   return(.Object)
    ^~~~~~~~~~~~~~~

R/mapReduce.R:53:3: style: Variable or function name should be lowerCamelCase.

BsumVec <- reduced[fullRasterVals] # join
  ^~~~~~~

R/neighbourhood.R:112:1: style: Variable or function name should be lowerCamelCase.

adj.raw <- function(x = NULL, cells, directions = 8, sort = FALSE, pairs = TRUE,
^~~~~~~

R/neighbourhood.R:114:21: style: Variable or function name should be lowerCamelCase.

match.adjacent = FALSE, cutoff.for.data.table = 2e3,
                    ^~~~~~~~~~~~~~

R/neighbourhood.R:114:45: style: Variable or function name should be lowerCamelCase.

match.adjacent = FALSE, cutoff.for.data.table = 2e3,
                                            ^~~~~~~~~~~~~~~~~~~~~

R/neighbourhood.R:233:1: style: Lines should not be more than 100 characters.

​              ((adj[, "from"] %% numCol + adj[, "to"] %% numCol) == 1)) # | #right & left edge cells, with neighbours wrapped
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/neighbourhood.R:238:1: style: Lines should not be more than 100 characters.

​              ((adj[, "from"] %% numCol + adj[, "to"] %% numCol) == 1)) # | #right & left edge cells, with neighbours wrapped
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/neighbourhood.R:297:1: style: Lines should not be more than 100 characters.

​              ((from %% numCol + to %% numCol) == 1))# | #right & left edge cells, with neighbours wrapped
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/neighbourhood.R:813:29: style: Variable or function name should be lowerCamelCase.

setGeneric("wrap", function(X, bounds, withHeading) {
                            ^

R/neighbourhood.R:822:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds) {
                        ^

R/neighbourhood.R:839:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds) {
                        ^

R/neighbourhood.R:849:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds) {
                        ^

R/neighbourhood.R:850:5: style: Variable or function name should be lowerCamelCase.

X <- wrap(X, bounds = extent(bounds))
    ^

R/neighbourhood.R:859:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds) {
                        ^

R/neighbourhood.R:860:5: style: Variable or function name should be lowerCamelCase.

X <- wrap(X, bounds = extent(bounds))
    ^

R/neighbourhood.R:869:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds) {
                        ^

R/neighbourhood.R:872:7: style: Variable or function name should be lowerCamelCase.

X <- wrap(X, bounds = extent(bounds))
      ^

R/neighbourhood.R:884:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds, withHeading) {
                        ^

R/neighbourhood.R:909:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds, withHeading) {
                        ^

R/neighbourhood.R:910:7: style: Variable or function name should be lowerCamelCase.

X <- wrap(X, bounds = extent(bounds), withHeading = withHeading)
      ^

R/neighbourhood.R:919:25: style: Variable or function name should be lowerCamelCase.

definition = function(X, bounds, withHeading) {
                        ^

R/neighbourhood.R:922:7: style: Variable or function name should be lowerCamelCase.

X <- wrap(X, bounds = extent(bounds), withHeading = withHeading)
      ^

R/neighbourhood.R:1059:40: style: Commas should always have a space after.

cc <- cbind(pureCircle2[, "x"] - xy[,"x"], pureCircle2[, "y"] - xy[, "y"])
                                       ^

R/probability.R:41:35: style: Place a space before left parenthesis, except in a function call.

1 / sqrt(var * 2 * pi) * exp(-((theta - mu + 2 * pi * k) ^ 2) / (2 * var))
                                  ^

R/probability.R:44:3: style: Variable or function name should be lowerCamelCase.

Next <- term(theta, mu, var, k)
  ^~~~

R/probability.R:45:3: style: Variable or function name should be lowerCamelCase.

Last <- Next
  ^~~~

R/RcppExports.R:68:20: style: Variable or function name should be lowerCamelCase.

runifC <- function(N) {
                   ^

R/RcppExports.R:71:1: style: Trailing blank lines are superfluous.

^

R/SELES.R:53:23: style: Variable or function name should be lowerCamelCase.

numAgents <- function(N, probInit) {
                      ^

R/spades-tools-deprecated.R:53:1: style: Trailing blank lines are superfluous.

^

R/splitRaster.R:67:7: style: Place a space before left parenthesis, except in a function call.

if(!is.na(path)){
      ^

R/splitRaster.R:116:1: style: Lines should not be more than 100 characters.

​      clusterApplyLB(cl = cl, x = seq_along(extents), fun = croppy, e = extents, r = r, path = path, rType = rType)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread.R:538:8: style: Commented code should be removed.

#isNASpreadProb <- is.na(spreadProb[])
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread.R:540:11: style: Commented code should be removed.

#   isNASpreadProb <- is.na(spreadProb[])
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread.R:541:11: style: Commented code should be removed.

#   spreadProb[isNASpreadProb] <- 0L
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread.R:942:41: style: Place a space before left parenthesis, except in a function call.

notDupsEvents <- notDups[-(1:(nrSpreads - nrPotentials))]
                                        ^

R/spread2.R:5:1: style: Lines should not be more than 100 characters.

"quantityAdj", "quantityAdj2", "state", "size", "tooBigByNCells", "V1", "proportion"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:674:12: style: Commented code should be removed.

#pureCircle <- unique(pureCircle)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:759:13: style: Commented code should be removed.

# colnamesDtPot <- colnames(dtPotential)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:760:13: style: Commented code should be removed.

# ll <-  lapply(colnamesDtPot, function(x) dtPotential[[x]][!spreadProbNA])
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:761:13: style: Commented code should be removed.

# names(ll) <- colnamesDtPot
            ^~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:762:13: style: Commented code should be removed.

# dtPotential <- as.data.table(ll)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:772:1: style: Lines should not be more than 100 characters.

​                                                                   .I[sample.int(length(numNeighs), size = numNeighs, prob = spreadProbRel)],
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:787:7: style: Variable or function name should be lowerCamelCase.

NAaSP <- !is.na(actualSpreadProb)
      ^~~~~

R/spread2.R:789:42: style: Commas should always have a space after.

dtPotential <- dtPotential[NAaSP,]
                                         ^

R/spread2.R:830:1: style: Lines should not be more than 100 characters.

# this is to prevent overlap within an event... in some cases, overlap within event is desired, so skip this block
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:848:1: style: Lines should not be more than 100 characters.

#successCells <- na.omit(successCells[!dupsWithinDtPotential]) # remove the dupsWithinDtPotential
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/spread2.R:848:10: style: Commented code should be removed.

#successCells <- na.omit(successCells[!dupsWithinDtPotential]) # remove the dupsWithinDtPotential
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-examples.R:3:47: style: Opening curly braces should never go on their own line and should always be followed by a new line.

if (grepl("VIC-", Sys.info()["nodename"]))  { # for debugging only
                                              ^

tests/testthat/test-examples.R:4:11: style: Commented code should be removed.

​    cat("#START##############\n", file = tmpExFile, append = FALSE)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-examples.R:14:15: style: Closing curly-braces should always be on their own line, unless it's followed by an else.

​    setwd(owd)}
              ^

tests/testthat/test-examples.R:16:46: style: Opening curly braces should never go on their own line and should always be followed by a new line.

if (grepl("VIC-", Sys.info()["nodename"])) { # for debugging only
                                             ^

tests/testthat/test-examples.R:17:1: style: Lines should not be more than 100 characters.

​    cat(paste("All files exist: ", isTRUE(all(file.exists(exFiles))), "\n"), file = tmpExFile, append = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-examples.R:22:48: style: Opening curly braces should never go on their own line and should always be followed by a new line.

if (grepl("VIC-", Sys.info()["nodename"])) { # for debugging only
                                               ^

tests/testthat/test-mapReduce.R:23:4: style: Commented code should be removed.

#expect_equal(sort(unique(getValues(biomass))), sort(reducedDT$biomass))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:27:5: style: Commented code should be removed.

#   library(data.table)
    ^~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:28:5: style: Commented code should be removed.

#   library(raster)
    ^~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:31:6: style: Commented code should be removed.

#    detach("package:data.table")
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:35:5: style: Commented code should be removed.

#   ras <- raster(extent(0,15,0,15), res=1)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:36:5: style: Commented code should be removed.

#   fullRas <- randomPolygons(ras, numTypes=5, speedup=1, p=0.3)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:37:5: style: Commented code should be removed.

#   names(fullRas) <- "mapcodeAll"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:38:5: style: Commented code should be removed.

#   uniqueComms <- raster::unique(fullRas)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:42:7: style: Commented code should be removed.

#     biomass=rnbinom(length(uniqueComms), mu=4000, 0.4)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:44:5: style: Commented code should be removed.

#   biomass <- rasterizeReduced(reducedDT, fullRas, "biomass")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:46:5: style: Commented code should be removed.

#   expect_equal(sort(unique(getValues(biomass))), sort(reducedDT$biomass))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:47:5: style: Commented code should be removed.

#   expect_equal(length(unique(getValues(biomass))), length(unique(getValues(fullRas))))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:49:5: style: Commented code should be removed.

#   setkey(reducedDT, biomass)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:50:5: style: Commented code should be removed.

#   communities <- rasterizeReduced(reducedDT, fullRas, "communities")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:51:5: style: Commented code should be removed.

#   expect_equal(sort(unique(getValues(communities))), sort(reducedDT$communities))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:52:5: style: Commented code should be removed.

#   expect_equal(length(unique(getValues(communities))), length(unique(getValues(fullRas))))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:56:5: style: Commented code should be removed.

#   library(data.table)
    ^~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:57:5: style: Commented code should be removed.

#   library(raster)
    ^~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:60:6: style: Commented code should be removed.

#    detach("package:data.table")
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:64:5: style: Commented code should be removed.

#   ras <- raster(extent(0, 15, 0, 15), res = 1)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:65:5: style: Commented code should be removed.

#   fullRas <- randomPolygons(ras, numTypes = 5, speedup = 1, p = 0.3)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:67:5: style: Commented code should be removed.

#   uniqueComms <- raster::unique(fullRas)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:71:7: style: Commented code should be removed.

#     biomass=rnbinom(length(uniqueComms), mu = 4000, 0.4)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:73:5: style: Commented code should be removed.

#   biomass <- rasterizeReduced(reducedDT, fullRas, "biomass")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:75:5: style: Commented code should be removed.

#   setkey(reducedDT, biomass)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:76:5: style: Commented code should be removed.

#   communities <- rasterizeReduced(reducedDT, fullRas, "communities")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:77:5: style: Commented code should be removed.

#   expect_equal(sort(unique(getValues(communities))), sort(reducedDT$communities))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:81:5: style: Commented code should be removed.

#   library(data.table)
    ^~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:82:5: style: Commented code should be removed.

#   library(raster)
    ^~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:85:6: style: Commented code should be removed.

#    detach("package:data.table")
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:89:5: style: Commented code should be removed.

#   ras <- raster(extent(0,15,0,15), res=1)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:90:5: style: Commented code should be removed.

#   fullRas <- randomPolygons(ras, numTypes=5, speedup=1, p=0.3)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:91:5: style: Commented code should be removed.

#   names(fullRas) <- "mapcodeAll"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:92:5: style: Commented code should be removed.

#   uniqueComms <- raster::unique(fullRas)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:96:7: style: Commented code should be removed.

#     biomass=rnbinom(length(uniqueComms), mu=4000, 0.4)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:98:5: style: Commented code should be removed.

#   biomass <- rasterizeReduced(reducedDT, fullRas, "biomass")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R💯5: style: Commented code should be removed.

#   setkey(reducedDT, biomass)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:101:5: style: Commented code should be removed.

#   communities <- rasterizeReduced(reducedDT, fullRas, "communities")
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-mapReduce.R:102:5: style: Commented code should be removed.

#   expect_equal(length(unique(getValues(communities))), length(unique(getValues(fullRas))))
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-randomPolygon.R:25:60: style: Put spaces around all infix operators.

​  expect_true(base::abs(base::abs(polyArea - area)) <  area/4) ## TODO: why is this area/4?
                                                          ~^~

tests/testthat/test-splitRaster.R:148:38: style: Commas should always have a space after.

​  expect_identical(dataType(y4[[1]]),"INT1U")
                                     ^

tests/testthat/test-splitRaster.R:165:1: style: Lines should not be more than 100 characters.

tmpdir <- file.path(tempdir(), "splitRaster-test-parallel") %>% reproducible::checkPath(create = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-splitRaster.R:168:8: style: Commented code should be removed.

#detach("package:raster")
       ^~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-splitRaster.R:226:1: style: Lines should not be more than 100 characters.

tmpdir <- file.path(tempdir(), "splitRaster-test-large") %>% reproducible::checkPath(create = TRUE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-splitRaster.R:264:4: style: Commented code should be removed.

#expect_equal(min(values(m)), min(values(r))) ## Error: cannot allocate vector of size 4.8 Gb
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-splitRaster.R:283:4: style: Commented code should be removed.

#expect_equal(max(values(m1)), max(values(r)))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-splitRaster.R:284:4: style: Commented code should be removed.

#expect_equal(min(values(m1)), min(values(r)))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread.R:209:1: style: Lines should not be more than 100 characters.

if (interactive()) Plot(circEdge, addTo = "circs", cols = c("transparent", rainbow(numCircs)[whCirc]))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:148:4: style: Commented code should be removed.

#quickDT <- data.table(id = seq_along(sams), initialPixels = sams, key = "id")
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:150:4: style: Commented code should be removed.

#cirOut <- quickDT[cirOut, on = ]
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:473:1: style: Lines should not be more than 100 characters.

##                                    expr       min        lq      mean   median        uq       max neval
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:474:1: style: Lines should not be more than 100 characters.

##         iterativeFun(ras, FALSE, n, sp)  3.096979 12.642477  73.02248 35.17520  91.10528  764.4073   300
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:475:1: style: Lines should not be more than 100 characters.

##      nonIterativeFun(ras, FALSE, n, sp)  1.509484  6.555565  31.18444 14.91066  42.78317  158.5237   300
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:476:1: style: Lines should not be more than 100 characters.

##           origSpread(ras, FALSE, n, sp)  5.154006  7.555631  14.87158 11.49005  17.50599  231.5487   300
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:477:1: style: Lines should not be more than 100 characters.

## origSpreadIterations(ras, FALSE, n, sp) 10.754669 51.524368 141.48620 93.61996 169.10808 2110.2683   300
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:688:38: style: Place a space before left parenthesis, except in a function call.

ciCentre[seq_len(ncell(ciCentre))[-(ncell(ciCentre) / 2 - ncol(ciCentre) / 2)]] <- NA_integer_
                                     ^

tests/testthat/test-spread2.R:884:1: style: Lines should not be more than 100 characters.

spreadProb = 0.23, persistProb = 0, iterations = 10, directions = 8L, plot.it = FALSE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:886:1: style: Lines should not be more than 100 characters.

spreadProb = 0.23, persistProb = 0.8, iterations = 10, directions = 8L, plot.it = FALSE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:891:3: style: Variable or function name should be lowerCamelCase.

M <- matrix(0.8, nrow = 50, ncol = 50)
  ^

tests/testthat/test-spread2.R:898:35: style: Put spaces around all infix operators.

start <- c(50, length(landscape)-49)
                                 ~^~

tests/testthat/test-spread2.R:902:1: style: Lines should not be more than 100 characters.

spreadProb = 0.23, persistProb = persistRas, iterations = 10, directions = 8L,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/testthat/test-spread2.R:916:14: style: Use <-, not =, for assignment.

spreadProb = landscape
             ^

tests/testthat/test-spread2.R:918:72: style: Commas should always have a space after.

​  expect_silent(spread2(landscape = landscape, spreadProb = spreadProb,start = start,
                                                                       ^

@PredictiveEcology PredictiveEcology deleted a comment from lintr-bot Jul 4, 2018

@achubaty achubaty merged commit 5c255de into PredictiveEcology:development Jul 5, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.