Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iflint1 committed Nov 17, 2023
1 parent 3aee94b commit f3d96b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 7 additions & 1 deletion tests/testthat/test-compute_G2.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ test_that("compute_G2 works with either a sequence or a list of fits", {
other <- ppjsdm::rppp(lambda = 100)
fit <- ppjsdm::gibbsm(configuration)
other_fit <- ppjsdm::gibbsm(other)
expect_equal(compute_G2(fit, other_fit), compute_G2(list = list(fit, other_fit)))

set.seed(1)
result1 <- ppjsdm::compute_G2(fit, other_fit)

set.seed(1)
result2 <- ppjsdm::compute_G2(list = list(fit, other_fit))
expect_equal(result1, result2)
})
1 change: 0 additions & 1 deletion tests/testthat/test-compute_papangelou.R
Original file line number Diff line number Diff line change
Expand Up @@ -559,4 +559,3 @@ test_that("Subsetting types for plot_papangelou with covariates", {
type = "a",
grid_steps = 10), NA)
})

11 changes: 3 additions & 8 deletions tests/testthat/test-gibbsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,7 @@ test_that("gibbsm works with infinite saturation for Exponential/Square exponent
})

test_that("gibbsm can handle points on the boundary of a window", {
library(spatstat)

covariates <- as.im(function(x, y) x - 0.5, W = owin())
covariates <- list(function(x, y) x - 0.5)

set.seed(1)

Expand All @@ -390,17 +388,15 @@ test_that("gibbsm can handle points on the boundary of a window", {
y = c(configuration$y, c(0, 0.5, 1, 0, 0.5, 1, 0, 0.5, 1)))

# Points land exactly on the border: no warning
expect_warning(ppjsdm::gibbsm(configuration, covariates = list(covariates)), NA)
expect_warning(ppjsdm::gibbsm(configuration, covariates = covariates), NA)
})

# TODO: This test is problematic: the stratified point process G2 computation requires an independent draw of the dummy points
# WITH THE EXACT SAME NUMBER OF POINTS. But if there are some covariates with NA values, the dummy points with NA values on them are removed.
# The same is done on the independent draw... but in the end the same cells need not be included.
# Solving this is not at all straightforward, so commenting the test for now.
# test_that("gibbsm can handle summary of fit with NA covariate values", {
# library(spatstat)
#
# covariates <- list(x = as.im(function(x, y) ifelse(x < 0.5, NA, x - 0.5), W = owin()))
# covariates <- list(x = function(x, y) ifelse(x < 0.5, NA, x - 0.5))
#
# set.seed(1)
#
Expand All @@ -410,4 +406,3 @@ test_that("gibbsm can handle points on the boundary of a window", {
# expect_error(summary(fit), NA)
# })


0 comments on commit f3d96b5

Please sign in to comment.