Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • multiApply multiApply
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Computational Earth SciencesComputational Earth Sciences
  • multiApplymultiApply
  • Issues
  • #20
Closed
Open
Issue created May 27, 2025 by Carlos Delgado Torres@cdelgado

List names of data inputs is not used, only the order

Hi @vagudets, @abatalla, @tkariyat,

I found a bug in Apply(). When data is provided as a named list, the names of the list are not used for the arguments to be passed in the correct order to the function. For instance, my function fun has three arguments (x,y,z). If data = list(x = x, y = y, z = z), the result is different than if data = list(x = x, z = z, y = y).

library(multiApply)

fun <- function(x,y,z){
  return(x+y-z)
}

x <- array(rnorm(1000), dim = c(lat = 2, lon = 5))
y <- array(rnorm(1000), dim = c(lat = 2, lon = 5))
z <- array(rnorm(1000), dim = c(lat = 2, lon = 5))

res_ordered_named <- Apply(data = list(x = x, y = y, z = z), fun = fun, target_dims = NULL, ncores = 1)$output1
res_notordered_named <- Apply(data = list(x = x, z = z, y = y), fun = fun, target_dims = NULL, ncores = 1)$output1
res_ordered_notnamed <- Apply(data = list(x, y, z), fun = fun, target_dims = NULL, ncores = 1)$output1
res_notordered_notnamed <- Apply(data = list(x, z, y), fun = fun, target_dims = NULL, ncores = 1)$output1

identical(res_ordered_named, res_notordered_named) # FALSE
identical(res_ordered_named, res_ordered_notnamed) # TRUE
identical(res_notordered_named, res_notordered_notnamed) # TRUE

This bug can be a big problem if any of our functions (those in s2dv, CSTools, ClimProjDiags, etc) that call Apply do not have the same order of the arguments as the atomic function, as well as if any of us is using Apply in their scripts (it's how I realised about this bug). I think all of them do have the same order, but I think it is worth checking it (I checked some in s2dv and they are not affected). I would also check in SUNSET, just in case.

Thanks a lot in advance,
Carlos @nperez @vtorralba @eduzenli

Edited May 27, 2025 by vagudets
Assignee
Assign to
Time tracking