Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Computational Earth Sciences
multiApply
Commits
0f34581a
Commit
0f34581a
authored
Jan 21, 2019
by
Nicolau Manubens Gil
Browse files
Merge branch 'master' into 'production'
Master See merge request
!18
parents
89c2af6a
5d5cb26e
Pipeline
#944
passed with stage
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
0f34581a
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"),
...
...
R/Apply.R
View file @
0f34581a
...
...
@@ -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
)
}
...
...
multiApply-manual.pdf
View file @
0f34581a
No preview for this file type
tests/testthat/test-use-cases.R
View file @
0f34581a
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment