Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • SUNSET SUNSET
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 42
    • Issues 42
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • 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
  • Earth SciencesEarth Sciences
  • SUNSETSUNSET
  • Issues
  • #34
Closed
Open
Issue created Aug 26, 2022 by vagudets@vagudetsMaintainer

Bug: Compute_probs() failing when requesting probabilities with more than 3 bins if the data has NAs

I found this bug in the Compute_probs() function in modules/Skill/s2s.probs.R that is called by compute_probabilities() in Skill.R. Mostly opening an issue to report on the solution to it.

This was the error that Apply() was raising:

Error in names(dim(arrays_of_results[[component]])) <- `*vtmp*` : 
  attempt to set an attribute on NULL
In addition: Warning messages:
1: In arrays_of_results[[component]][(1:prod(component_dims)) + (m -  :
  number of items to replace is not a multiple of replacement length
2: In arrays_of_results[[component]][(1:prod(component_dims)) + (m -  :
  number of items to replace is not a multiple of replacement length
3: In arrays_of_results[[component]][(1:prod(component_dims)) + (m -  :
  number of items to replace is not a multiple of replacement length

Ultimately I found that the source of the error was the hard-coding in the definition of the function to convert to probabilities:

if (na.rm == FALSE) {
  c2p <- function(x, t) {
  colMeans(convert2prob(as.vector(x), threshold = as.vector(t)))
  }
} else {
  c2p <- function(x, t) {
    if (any(!is.na(x))) {
      colMeans(convert2prob(as.vector(x), threshold = as.vector(t)))
    } else {
      c(NA, NA, NA)
    }
  }
}

The definition under the else condition can be generalized to any number of probability bins like so:

c2p <- function(x, t) {
  if (any(!is.na(x))) {
    colMeans(convert2prob(as.vector(x), threshold = as.vector(t)))
  } else {
    rep(NA, dim(t)[['bin']] + 1) # vector with as many NAs as probability bins.
  }
}

Victòria

Edited Aug 26, 2022 by vagudets
Assignee
Assign to
Time tracking