Skip to content

Commit

Permalink
Fixed updateData
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Aug 9, 2022
1 parent 34c0994 commit ab942c1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Authors@R: c(person("Adrian", "Baddeley",
Maintainer: Adrian Baddeley <Adrian.Baddeley@curtin.edu.au>
Depends: R (>= 3.5.0), spatstat.data (>= 2.999-999), spatstat.geom (>= 2.999-999), spatstat.random (>= 2.999-999), stats, graphics, grDevices, utils, methods, nlme
Imports: spatstat.utils (>= 2.999-999), spatstat.sparse (>= 2.999-999), goftest (>= 1.2-2), Matrix, abind
Suggests: sm, maptools (>= 0.9-9), gsl, locfit, spatial, fftwtools (>= 0.9-8), spatstat.linnet (>= 2.999-999), spatstat.model (>= 2.999-999), spatstat (>= 2.999-999)
Suggests: sm, maptools (>= 0.9-9), gsl, locfit, spatial, fftwtools (>= 0.9-8), spatstat.linnet (>= 2.999-999.016), spatstat.model (>= 2.999-999.022), spatstat (>= 2.999-999)
Additional_repositories: https://spatstat.r-universe.dev
Description: Functionality for exploratory data analysis and nonparametric analysis of
spatial data, mainly spatial point patterns,
Expand Down
37 changes: 30 additions & 7 deletions R/resolve.lambda.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#' resolve.lambdacross
#' resolve.reciplambda
#' validate.weights
#' updateData
#' updateData (generic)
#'
#' $Revision: 1.17 $ $Date: 2022/08/09 04:10:27 $
#' $Revision: 1.18 $ $Date: 2022/08/09 06:46:50 $

resolve.lambda <- function(X, lambda=NULL, ...) {
UseMethod("resolve.lambda")
Expand Down Expand Up @@ -357,14 +357,37 @@ validate.weights <- function(x, recip=FALSE, how = NULL,
}

updateData <- function(model, X, ...) {
## wrapper to refit the 'model' to new data 'X'
UseMethod("updateData")
}

updateData.default <- function(model, X, ..., warn=TRUE) {
## We only arrive here if spatstat.model is absent or out-of-date
if(warn)
warning("Model was not updated; this requires a recent version of spatstat.model",
call.=FALSE)
## for some bizarre reason, method dispatch often fails for this function
## so we do it by hand as a backup
if(warn) warning("Reached 'updateData.default'", call.=FALSE)
if(inherits(model, c("ppm", "kppm", "dppm", "slrm"))) {
if(requireNamespace("spatstat.model")) {
if(inherits(model, "ppm")) {
model <- spatstat.model::updateData.ppm(model, X)
} else if(inherits(model, "kppm")) {
model <- spatstat.model::updateData.kppm(model, X)
} else if(inherits(model, "dppm")) {
model <- spatstat.model::updateData.dppm(model, X)
} else if(inherits(model, "slrm")) {
model <- spatstat.model::updateData.slrm(model, X)
}
} else
if(warn)
warning("Model was not updated; this requires a recent version of spatstat.model", call.=FALSE)
} else if(inherits(model, "lppm")) {
if(requireNamespace("spatstat.linnet")) {
model <- spatstat.linnet::updateData.lppm(model, X)
} else
if(warn)
warning("Model was not updated; this requires a recent version of spatstat.linnet", call.=FALSE)
} else
if(warn)
warning("Unrecognised kind of 'model'; no update performed",
call.=FALSE)
return(model)
}

2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
date version nhelpfiles nobjects ndatasets Rlines srclines
"2022-05-25" "3.0-0" 224 500 0 30319 6183
"2022-08-09" "2.999-999.024" 226 507 0 30553 6183
"2022-08-09" "2.999-999.024" 226 507 0 30576 6183

0 comments on commit ab942c1

Please sign in to comment.