Commit 0f34581a authored by Nicolau Manubens Gil's avatar Nicolau Manubens Gil
Browse files

Merge branch 'master' into 'production'

Master

See merge request !18
parents 89c2af6a 5d5cb26e
Pipeline #944 passed with stage
Package: multiApply
Title: Apply Functions to Multiple Multidimensional Arrays or Vectors
Version: 2.1.0
Version: 2.1.1
Authors@R: c(
person("BSC-CNS", role = c("aut", "cph")),
person("Nicolau", "Manubens", , "nicolau.manubens@bsc.es", role = "aut"),
......
......@@ -506,7 +506,7 @@ Apply <- function(data, target_dims = NULL, fun, ...,
chunk_sizes <- c(chunk_sizes, total_size %% chunk_size)
}
fun_env <- new.env()
fun_env <- new.env(parent = parent.frame())
for (i in seq_along(extra_info)) {
assign(names(extra_info)[i], extra_info[[i]], envir = fun_env)
}
......
No preview for this file type
......@@ -1357,6 +1357,22 @@ test_that("Dimension names are propagated correctly.", {
f)
})
# Test nested environments are linked properly
test_that("Nested environments are linked properly.", {
#create input
forecast <- array(dim = c('31', '12', '4'),
rnorm(31 * 12 * 4))
names(dim(forecast)) <- c('sday', 'syear', 'ensemble')
anomaly_simple <- function(data) {
avg <- Apply(data, c('syear', 'ensemble'), mean)[[1]]
anom <- Apply(data, c('sday'), function(x) x - avg)[[1]]
return(anom)
}
anomaly <- anomaly_simple(forecast)
})
# TODOS:
# TESTS FOR MARGINS
# TESTS FOR DISORDERED TARGET_DIMS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment