Skip to content

Commit

Permalink
Merge branch 'fix_subsetting' into 'master'
Browse files Browse the repository at this point in the history
bugfix for subsetting via indices for time(year, month, day) dimensions

See merge request lpjml/lpjmlkit!88
  • Loading branch information
jnnsbrr committed Mar 15, 2024
2 parents 61dee0f + 557e1ea commit c9e4cbc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '2593407'
ValidationKey: '2613204'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'lpjmlkit: Toolkit for Basic LPJmL Handling'
version: 1.3.1
version: 1.3.2
date-released: '2024-03-15'
abstract: A collection of basic functions to facilitate the work with the Dynamic
Global Vegetation Model (DGVM) Lund-Potsdam-Jena managed Land (LPJmL) hosted at
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: lpjmlkit
Type: Package
Title: Toolkit for Basic LPJmL Handling
Version: 1.3.1
Version: 1.3.2
Authors@R: c(
person("Jannes", "Breier", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9055-6904")),
person("Sebastian","Ostberg", , "[email protected]", role = "aut", comment = c(ORCID = "0000-0002-2368-7015")),
Expand Down
2 changes: 1 addition & 1 deletion R/LPJmLData_subset.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ LPJmLData$set(
create_year_dimnames <- function(subset_list, data) {

if ("year" %in% names(subset_list) && is.numeric(subset_list[["year"]])) {
year_dimnames <- data$dimnames()$year
year_dimnames <- dimnames(data)$year
} else {
year_dimnames <- NULL
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Toolkit for Basic LPJmL Handling <a href=''><img src='inst/img/logo.png' align='right' height='139' /></a>

R package **lpjmlkit**, version **1.3.1**
R package **lpjmlkit**, version **1.3.2**

[![CRAN status](https://www.r-pkg.org/badges/version/lpjmlkit)](https://cran.r-project.org/package=lpjmlkit) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7773134.svg)](https://doi.org/10.5281/zenodo.7773134) [![R build status](https://github.com/PIK-LPJmL/lpjmlkit/workflows/check/badge.svg)](https://github.com/PIK-LPJmL/lpjmlkit/actions) [![codecov](https://codecov.io/gh/PIK-LPJmL/lpjmlkit/branch/master/graph/badge.svg)](https://app.codecov.io/gh/PIK-LPJmL/lpjmlkit) [![r-universe](https://pik-piam.r-universe.dev/badges/lpjmlkit)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -76,7 +76,7 @@ In case of questions / problems please contact Jannes Breier <jannesbr@pik-potsd

To cite package **lpjmlkit** in publications use:

Breier J, Ostberg S, Wirth S, Minoli S, Stenzel F, Müller C (2024). _lpjmlkit: Toolkit for Basic LPJmL Handling_. doi: 10.5281/zenodo.7773134 (URL: https://doi.org/10.5281/zenodo.7773134), R package version 1.3.1, <URL: https://github.com/PIK-LPJmL/lpjmlkit>.
Breier J, Ostberg S, Wirth S, Minoli S, Stenzel F, Müller C (2024). _lpjmlkit: Toolkit for Basic LPJmL Handling_. doi: 10.5281/zenodo.7773134 (URL: https://doi.org/10.5281/zenodo.7773134), R package version 1.3.2, <URL: https://github.com/PIK-LPJmL/lpjmlkit>.

A BibTeX entry for LaTeX users is

Expand All @@ -85,7 +85,7 @@ A BibTeX entry for LaTeX users is
title = {lpjmlkit: Toolkit for Basic LPJmL Handling},
author = {Jannes Breier and Sebastian Ostberg and Stephen Björn Wirth and Sara Minoli and Fabian Stenzel and Christoph Müller},
year = {2024},
note = {R package version 1.3.1},
note = {R package version 1.3.2},
doi = {10.5281/zenodo.7773134},
url = {https://github.com/PIK-LPJmL/lpjmlkit},
}
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/test-LPJmLData_subset_transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ test_integrity <- function(output) {
} else {
# Test for equal dimnames of lat, lon in data and those of underlying grid
expect_equal(dimnames_data$lat,
dimnames(output$grid)$lat)
dimnames(output$grid)$lat)
expect_equal(dimnames_data$lon,
dimnames(output$grid)$lon)
dimnames(output$grid)$lon)
}

# Check for two cases "time" or "year_month_day"
if ("time" %in% names(dim_data)) {
# Test for equal length of time steps in data and meta data (nyear * nstep)
expect_equal(dim_data[["time"]],
output$meta$nyear * output$meta$nstep)
output$meta$nyear * output$meta$nstep)
# Test for equal dimnames of time steps in data and those constructed by
# meta data with create_time_names function (nstep, firstyear, nyear)
expect_equal(
Expand Down Expand Up @@ -96,7 +96,7 @@ test_integrity <- function(output) {
# by meta data of output
expect_true(
all(as.vector(stats::na.omit(output$grid$data)) %in%
seq(output$meta$firstcell, length.out = output$meta$ncell))
seq(output$meta$firstcell, length.out = output$meta$ncell))
)
}
}
Expand Down Expand Up @@ -208,7 +208,7 @@ test_that("test transform (space) method", {
# Explicitly load grid
output$add_grid("../testdata/output/grid.bin.json")
output$transform(to = c("year_month_day", "lon_lat"))
output$subset(year = as.character(2005:2008),
output$subset(year = 5:8,
month = 6:9,
lat = c("55.25", "55.75", "56.25", "56.75"))
output$transform(to = "cell")
Expand All @@ -221,7 +221,7 @@ test_that("test transform (space) method", {
output2$add_grid("../testdata/output/grid.bin.json")
output2$transform(to = c("year_month_day", "lon_lat"))
output2$subset(year = as.character(2005:2008),
month = 6:9,
month = as.character(6:9),
lat = c("55.25", "55.75", "56.25", "56.75"))
output2$transform(to = "cell")
test_integrity(output2)
Expand Down

0 comments on commit c9e4cbc

Please sign in to comment.