Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • ClimProjDiags ClimProjDiags
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • ClimProjDiagsClimProjDiags
  • Merge requests
  • !28

Bugfix for Subset() when the output dimension length is 1

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged aho requested to merge develop-Subset_dropT into master Aug 25, 2022
  • Overview 2
  • Commits 3
  • Pipelines 0
  • Changes 18

Hi @cdelgado

You mentioned that Subset() has problems with drop = T. I did some tests and got the following errors. Can you confirm if these are the errors you found?

dat1 <- array(1:20, dim = c(dat = 1, lat = 2, lon = 10))
# case 1
Subset(dat1, c('lon'), list(2), drop = TRUE)
Error in names(metadata[["dim"]]) <- dim_names : 
  attempt to set an attribute on NULL
# case 2
Subset(dat1, c('dat', 'lat', 'lon'), list(1, 1, 2), drop = 'selected')
Error in attributes(subset) <- metadata : 
  length-0 dimension vector is invalid

The problem happened when the output dimension length is 1 only. For example, case 1 above should have [lat = 2], and case 2 should have [1].

The bug is fixed in this branch. I've done as many tests as I can to make sure it works well. If you wanna try, you can source("https://earth.bsc.es/gitlab/es/ClimProjDiags/-/raw/develop-Subset_dropT/R/Subset.R"). Let me know if it solves the bug you found, thanks!

Cheers,
An-Chi

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: develop-Subset_dropT