Problem when arrays have dimnames
As reported by @bertvs, multiApply doesn't seem able to handle arrays with dimnames attributes.
Below is a very simple test that gives an error in multiApply:
mod <- seq(1, 2 * 3)
obs <- seq(1, 2 * 3)
dim(mod) <- c(dataset = 2, member = 3)
dim(obs) <- c(dataset = 2, member = 3)
dimnames(mod)[[1]] <- c("MF", "UKMO")
dimnames(obs)[[1]] <- c("MF", "UKMO")
test.fun <- function(obs, mod) {return(obs == mod)}
outp <- Apply(data = list(obs = obs, mod = mod),
target_dims = list(obs = c("member"), mod = c("member")),
fun = test.fun
)
Error in attributes(x) <- c(attributes(x), attr_bk) :
length of 'dimnames' [1] not equal to array extent
The problem also occurs when dimnames are used only once, for either mod or obs but the error disappears when using no dimnames.
The use of the use_attributes (e.g. use_attributes = list(mod = c("dimnames")) argument also causes problems.