[英]spatstat integer overflow error in Kcross and crosspairs
I'm working with spatstat 2.3-4 in R 4.1.0 on a 64bit windows 10 pro machine.我在 64 位 windows 10 pro 机器上使用 R 4.1.0 中的 spatstat 2.3-4。 Recently I ran into the integer-overflow error while using
Kcross
with a large number of points (ie the number of combination exceeded .Machine$integer.max
).最近我在使用具有大量点的
Kcross
时遇到了整数溢出错误(即组合数超过.Machine$integer.max
)。 For example:例如:
W <- as.owin(list(xrange = c(688.512, 17879.746) , yrange = c(-27996.842, -7759.813)))
cells1 <- runifpoint(n = 8062, win = W)
cells2 <- runifpoint(n = 1768988, win = W)
cells3 <- superimpose(tumor = cells1 , bcell = cells2)
Kcross(cells3 , r = seq(0,200,by=5) , "tumor" , "bcell" , correction="none") # error
# Error in if (nXY <= 1024) { : missing value where TRUE/FALSE needed
# In addition: Warning message: In nX * nY : NAs produced by integer overflow
8062 * 1768988 > .Machine$integer.max
# [1] TRUE
After a lot of struggling I realized that the error comes from this part of crosspairs
:经过一番挣扎后,我意识到错误来自这部分
crosspairs
:
if (spatstat.options("crosspairs.newcode")) {
nXY <- nX * nY
if (nXY <= 1024) {
nsize <- 1024
}
I could "fix" the error by changing spatstat options: spatstat.options("crosspairs.newcode" = FALSE)
.我可以通过更改 spatstat 选项来“修复”错误:
spatstat.options("crosspairs.newcode" = FALSE)
。
Is this the way to deal with the error?这是处理错误的方法吗?
UPDATE: As Adrian.Baddeley answered below, where is now a new spatstat.geom
version on GitHub (currently: v2.4.-0.029) in which the bug is fixed.更新:正如 Adrian.Baddeley 在下面回答的那样,现在 GitHub 上的一个新的
spatstat.geom
版本(当前:v2.4.-0.029)修复了错误。 The new version works fine without the change of the options.新版本在不更改选项的情况下工作正常。
This is a bug in some relatively new code to speed up the underlying function crosspairs.ppp()
.这是一些相对较新的代码中的错误,用于加速底层 function
crosspairs.ppp()
。 Until a new version of spatstat.geom
is available you can workaround the problem by setting spatstat.options("crosspairs.newcode" = FALSE)
as suggested.在新版本的
spatstat.geom
可用之前,您可以按照建议设置spatstat.options("crosspairs.newcode" = FALSE)
来解决该问题。
The bug is fixed in the development version of spatstat.geom
available at the GitHub repository该错误已在GitHub 存储库中可用的 spatstat.geom
spatstat.geom
版本中修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.