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

CST_Subset(): Fix bug that caused incorrect subsetting of coordinate values when only subsetting along one dimension

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged vagudets requested to merge develop-CST_Subset_coords_indices into master Dec 21, 2023
  • Overview 3
  • Commits 2
  • Pipelines 2
  • Changes 2

Hi @erifarov,

While doing some tests for CST_SaveExp() I found this bug in CST_Subset:

library(CSTools)
exp <- CSTools::lonlat_prec_st
exp_subset <- CST_Subset(exp, along = "ftime", indices = 1:3, drop = F)
exp_subset$dims
# dataset     var  member   sdate   ftime     lat     lon 
#       1       1       6       3       3       4       4 
exp_subset$coords$ftime
# [1] 1
# attr(,"indices")
# [1] TRUE

As you can see, $coords$ftime should have values 1, 2, 3 but instead only had one. After investigating a little bit I found out that is is because at line 90: index <- indices[[dimension]] index becomes unlisted due to the use of [[ and then .subset_with_attrs() only retrieves the first value of the array.

I have fixed this by changing the line to index <- indices[dimension] so that index remains a list with only the element dimension. Please let me know if you have any questions or if you think there is any problem with this fix.

Thanks,

Victòria

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