Skip to content

Commit

Permalink
+ version 1.0.1 - see news.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhanson committed Mar 6, 2016
1 parent 575d41e commit d1952c4
Show file tree
Hide file tree
Showing 100 changed files with 797 additions and 659 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
^\.Rproj\.user$
^.Rhistory$
[~]
appveyor.yml
.travis.yml

6 changes: 6 additions & 0 deletions .directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Dolphin]
Timestamp=2016,3,5,16,21,34
Version=3

[Settings]
HiddenFilesShown=true
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
language: r
sudo: required
warnings_are_errors: true

os:
- linux
- osx

env:
global:
- NOT_CRAN=true
- _R_CHECK_FORCE_SUGGESTS_=False

before_install:
- echo "TRAVIS_OS_NAME = $TRAVIS_OS_NAME"
- echo "options(repos = c(CRAN='http://cran.rstudio.com'))" > ~/.Rprofile

r_binary_packages:
- sp
- rgdal
- raster
- Rcpp
- plyr
- gdalUtils
- shape
- ape
- fastcluster
- PBSmapping
- RgoogleMaps
- testthat
- data.table
- doSNOW
- RColorBrewer
- scales
- vegan

r_packages:
- covr
- rmarkdown
- testthat

after_success:
- Rscript -e 'covr::codecov()'

20 changes: 14 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ Description: This R package contains decision support tools for reserve
Most of the functions that involve intensive data processing use code
compiled in C++, provide options to run processing in parallel, or can make
use of other software to reduce run time.
License: GNU AFFERO GENERAL PUBLIC LICENSE (version 3)
License: AGPL-3
URL: https://github.com/paleo13/marxan
LazyData: true
Collate:
'dependencies.R'
'RcppExports.R'
'marxan-internal.R'
'misc.R'
'generics.R'
'zonalSum.R'
'misc.R'
'calcPuVsSpeciesData.R'
'calcBoundaryData.R'
'generics.R'
'MarxanData.R'
'MarxanOpts.R'
'MarxanResults.R'
Expand All @@ -47,15 +47,23 @@ Imports:
fastcluster,
PBSmapping,
RgoogleMaps,
testthat,
data.table,
doSNOW,
knitr,
rmarkdown,
RColorBrewer,
scales,
snow,
vegan
LinkingTo: Rcpp
VignetteBuilder: knitr
Suggests:
rmarkdown,
testthat,
knitr
BinaryFiles: 'bin/MarOpt_v243_Linux32',
'bin/MarOpt_v243_Linux64',
'bin/MarOpt_v243_Mac32',
'bin/MarOpt_v243_Mac64',
'bin/Marxan.exe',
'bin/Marxan_x64.exe'
SystemRequirements: C++11
RoxygenNote: 5.0.1
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method("costs<-",MarxanData)
S3method("costs<-",MarxanSolved)
Expand Down Expand Up @@ -172,9 +172,12 @@ exportClasses(MarxanResults)
exportClasses(MarxanSolved)
exportClasses(MarxanUnsolved)
exportMethods(SpatialPolygons2PolySet)
exportMethods(cache)
exportMethods(initialize)
exportMethods(is.cached)
exportMethods(is.comparable)
exportMethods(plot)
exportMethods(rasterize.gdal)
exportMethods(show)
exportMethods(spplot)
exportMethods(zonalSum)
Expand Down
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
marxan 1.0.1
--------
* Fixed bug in boundary data calculations.
* Fixed bug with n_preallocate in SpatialPolygons2Polyset
* Pass CRAN manual checks - still failing some checks
* Automated tests using Travis CI and AppVeyor.
* Replace Makevars files with SystemRequirements in DESCRIPTION


marxan 1.0.0
--------
* First major release.
Expand Down
36 changes: 22 additions & 14 deletions R/MarxanData.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,19 @@ setMethod(
#' @param puvspecies_spo "data.frame" with data in \code{puvspecies} ordered by 'species' column. Defaults to \code{NULL}, and will generate data from \code{puvspecies}.
#' @param skipchecks "logical" Skip data integrity checks? May improve speed for big data sets. Defaults to \code{FALSE}.
#' @param .cache "environment" used to cache calculations. Defaults to a new environment.
#' @param ... not used.
#' @note Generally, users are not encouraged to change arguments to \code{.cache}.
#' @return MarxanData object
#' @seealso \code{\link[PBSmapping]{PolySet}}, \code{\link{read.MarxanData}}, \code{\link{write.MarxanData}}, \code{\link{format.MarxanData}}, \code{\link{MarxanData-class}}.
#' @export
#' @examples
#' data(planningunits, species)
#' data(taspu, tasinvis)
#' x<-MarxanData(
#' planningunits@@data,
#' taspu@@data,
#' data.frame(id=1L, target=12, spf=23, name='species1', stringsAsFactors=FALSE),
#' calcPuVsSpeciesData(planningunits, species[[1]]),
#' calcBoundaryData(planningunits),
#' SpatialPolygons2PolySet(planningunits)
#' calcPuVsSpeciesData(taspu, tasinvis[[1]]),
#' calcBoundaryData(taspu),
#' SpatialPolygons2PolySet(taspu)
#' )
MarxanData<-function(pu, species, puvspecies, boundary, polygons=NULL, puvspecies_spo=NULL, skipchecks=FALSE, .cache=new.env(), ...) {
# convert factors to characters
Expand Down Expand Up @@ -332,6 +333,10 @@ write.MarxanData<-function(x, dir=getwd(), ...) {
#' @param polygons "SpatialPolygons" with planning unit data.
#' @param rasters "RasterLayer", "RasterStack", "RasterBrick" with species distribution data.
#' @param targets "numeric" vector for targets for each species (eg. 12), or "character" vector with percent-based targets (eg. '12\%'). Defaults to '20\%' for each species.
#' @param spf "numeric" species penalty factors.
#' @param sepdistance "numeric" species minimum separation distance.
#' @param sepnum "numeric" species seperated feature occurences.
#' @param targetocc "numeric" species occurence targets.
#' @param pu "data.frame" planning unit data; with "integer" 'id', "numeric" 'cost', "integer" 'status' columns. Default behaviour is to generate a table with all costs and statuses set to 1 and 0 (respectively).
#' @param species "data.frame" with species data; with "integer" 'id', "numeric" 'target', "numeric" 'spf', and "character" 'name' columns. Default behaviour is to base targets on \code{target} argument, set 'spf' to 1, and set 'names' use names of layers in \code{rasters} argument.
#' @param puvspecies "data.frame" pu vs. species data; with "species", "pu", and "amount" columns. Defaults to \code{NULL}, and will be calculated using \code{calcPuVsSpeciesData}.
Expand All @@ -342,9 +347,9 @@ write.MarxanData<-function(x, dir=getwd(), ...) {
#' @seealso \code{\link{MarxanData-class}}, \code{\link{MarxanData}}, \code{\link{read.MarxanData}}, \code{\link{write.MarxanData}}.
#' @export format.MarxanData
#' @examples
#' data(planningunits, species)
#' x<-MarxanData(planningunits, rasters=species, targets="10\%")
#' y<-MarxanData(planningunits, rasters=species)
#' data(taspu, tasinvis)
#' x<-MarxanData(taspu, rasters=tasinvis, targets="10%")
#' y<-MarxanData(taspu, rasters=tasinvis)
#' stopifnot(identical(x,y))
format.MarxanData<-function(polygons, rasters, targets="20%", spf=rep(1, nlayers(rasters)), sepdistance=rep(0, nlayers(rasters)), sepnum=rep(0L,nlayers(rasters)), targetocc=rep(0L,nlayers(rasters)), pu=NULL, species=NULL, puvspecies=NULL, puvspecies_spo=NULL, boundary=NULL, ..., verbose=FALSE) {
# init
Expand Down Expand Up @@ -640,7 +645,8 @@ setMethod(
)


#' @describeIn is.cached
#' @rdname is.cached
#' @export
setMethod(
f="is.cached",
signature(x="MarxanData", name="character"),
Expand All @@ -649,7 +655,8 @@ setMethod(
}
)

#' @describeIn cache
#' @rdname cache
#' @export
setMethod(
f="cache",
signature(x="MarxanData", name="character", y="ANY"),
Expand All @@ -658,7 +665,8 @@ setMethod(
}
)

#' @describeIn cache
#' @rdname cache
#' @export
setMethod(
f="cache",
signature(x="MarxanData", name="character", y="missing"),
Expand All @@ -668,7 +676,7 @@ setMethod(
)

#' @rdname is.comparable
#' export
#' @export
setMethod(
f="is.comparable",
signature(x="MarxanData", y="MarxanData"),
Expand Down Expand Up @@ -732,14 +740,14 @@ targets.MarxanData<-function(x) {
return(x)
}

#' @rdname maxtargets
#' @export
#' @describeIn maxtargets
maxtargets.MarxanData<-function(x) {
return(x@species$maxtargets)
}

#' @rdname maxtargets
#' @export
#' @describeIn maxtargets
`maxtargets<-.MarxanData`<-function(x, value) {
stopifnot(is.numeric(value) & !any(is.na(value)))
x@species$maxtargets<-value
Expand Down
6 changes: 3 additions & 3 deletions R/MarxanOpts.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ NULL
#' @slot VERBOSITY "integer" Amount of output displayed on the program screen. Defaults to 1L.
#' @slot NCORES "integer" Number of cores to use for processing. Defaults to 1L.

#' @note This class was not called "MarxanPars" due to the inevitable conflicts with \code{\link[base]{par}}.
#' @note This class was not called "MarxanPars" due to the inevitable conflicts with \code{\link[graphics]{par}}.
#' @export
setClass("MarxanOpts",
representation(
Expand Down Expand Up @@ -118,12 +118,12 @@ setClass("MarxanOpts",
#' @seealso \code{\link{MarxanOpts-class}}, \code{\link{read.MarxanOpts}}, \code{\link{write.MarxanOpts}}.
#' @export
#' @examples
#' x<-MarxanOpts(NCORES=4, NUMREPS=2, NUMITNS=5)
#' x<-MarxanOpts(NCORES=4L, NUMREPS=2L, NUMITNS=5L)
MarxanOpts<-function(..., ignore.extra=FALSE) {
x<-new('MarxanOpts')
args<-as.list(substitute(list(...)))[c(-1L)]
extra<-which(!names(args) %in% names(getSlots("MarxanOpts")))
if (length(extra)>0) {
if (length(extra)>0) {
if (ignore.extra) {
args<-args[-extra]
} else {
Expand Down
8 changes: 4 additions & 4 deletions R/MarxanResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NULL
#' @slot best "integer" with index of best solution.
#' @slot log "character" with Marxan log file (otuput_log.dat).
#' @export
#' @seealso \code{\link{MarxanResults}}, \code{\link{read.MarxanResults}}, \code{\link{write.MarxanResults}}.
#' @seealso \code{\link{MarxanResults}}, \code{\link{read.MarxanResults}}.
setClass("MarxanResults",
representation(
summary="data.frame",
Expand Down Expand Up @@ -384,7 +384,7 @@ dotchart.MarxanResults<-function(x, var="score", nbest=1, n=50) {
)
}

#' @describeIn is.cached
#' @rdname is.cached
setMethod(
f="is.cached",
signature(x="MarxanResults", name="character"),
Expand All @@ -393,7 +393,7 @@ setMethod(
}
)

#' @describeIn cache
#' @rdname cache
setMethod(
f="cache",
signature(x="MarxanResults", name="character", y="ANY"),
Expand All @@ -402,7 +402,7 @@ setMethod(
}
)

#' @describeIn cache
#' @rdname cache
setMethod(
f="cache",
signature(x="MarxanResults", name="character", y="missing"),
Expand Down
6 changes: 3 additions & 3 deletions R/MarxanSolved.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ print.MarxanSolved<-function(x) {
print.MarxanResults(x@results, FALSE)
}

# ' @export
#' @export
setMethod(
'show',
'MarxanSolved',
Expand Down Expand Up @@ -496,13 +496,13 @@ targets.MarxanSolved<-function(x) {
}

#' @export
#' @describeIn maxtargets
#' @rdname maxtargets
maxtargets.MarxanSolved<-function(x) {
return(maxtargets.MarxanData(x@data))
}

#' @export
#' @describeIn maxtargets
#' @rdname maxtargets
`maxtargets<-.MarxanSolved`<-function(x,value) {
stopifnot(is.numeric(value) & !any(is.na(value)))
x@data@species$maxtargets<-value
Expand Down
4 changes: 2 additions & 2 deletions R/MarxanUnsolved.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ targets.MarxanUnsolved<-function(x) {
}

#' @export
#' @describeIn maxtargets
#' @rdname maxtargets
maxtargets.MarxanUnsolved<-function(x) {
return(maxtargets.MarxanData(x@data))
}

#' @export
#' @describeIn maxtargets
#' @rdname maxtargets
`maxtargets<-.MarxanUnsolved`<-function(x,value) {
stopifnot(is.numeric(value) & !any(is.na(value)))
x@data@species$maxtargets<-value
Expand Down
14 changes: 7 additions & 7 deletions R/Polygons2PolySet.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ NULL
#'
#' @param x "SpatialPolygons" or "SpatialPolygonsDataFrame" object.
#' @param n_preallocate "integer" How much memory should be preallocated for processing? Ideally, this number should equal the number of vertices in the "SpatialPolygons" object. If dtaa processing is taking too long consider increasing this value.
#' @usage SpatialPolygons2PolySet(x, n=10000L)
#' @usage SpatialPolygons2PolySet(x, n_preallocate=10000L)
#' @return "PolySet" object.
#' @note Be aware that this function is designed to be as fast as possible, but as a result it depends on C++ code and if used inappropriately this function will crash R.
#' @seealso For a slower, more stable equivalent see \code{\link[maptools]{SpatialPolygons2PolySet}}.
#' @export
#' @examples
#' data(planningunits)
#' x <- SpatialPolygons2PolySet(planningunits)
#' data(taspu)
#' x <- SpatialPolygons2PolySet(taspu)
setGeneric("SpatialPolygons2PolySet", function(x, ...) standardGeneric("SpatialPolygons2PolySet"))

#' describeIn SpatialPolygons2PolySet
#' @rdname SpatialPolygons2PolySet
#' @export
setMethod(
"SpatialPolygons2PolySet",
signature(x="SpatialPolygonsDataFrame"),
function(x, n_preallocate = 10000L) {
return(rcpp_Polygons2PolySet(x@polygons))
return(rcpp_Polygons2PolySet(x@polygons, n_preallocate))
}
)

#' describeIn SpatialPolygons2PolySet
#' @rdname SpatialPolygons2PolySet
#' @export
setMethod(
"SpatialPolygons2PolySet",
signature(x="SpatialPolygons"),
function(x, n_preallocate = 10000L) {
return(rcpp_Polygons2PolySet(x@polygons))
return(rcpp_Polygons2PolySet(x@polygons, n_preallocate))
}
)

Expand Down
Loading

0 comments on commit d1952c4

Please sign in to comment.