Skip to content

Commit

Permalink
Merge branch 'add_file_extension_package_option' into 'main'
Browse files Browse the repository at this point in the history
Add file extension package option

See merge request lpjml/lpjmlstats!10
  • Loading branch information
jnnsbrr committed May 15, 2024
2 parents 8526935 + 1ad82c7 commit cffb000
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '337246'
ValidationKey: '397120'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -35,7 +35,7 @@ jobs:
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest version

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9

Expand All @@ -48,6 +48,11 @@ jobs:
shell: Rscript {0}
run: lucode2:::validkey(stopIfInvalid = TRUE)

- name: Verify that lucode2::buildLibrary was successful
if: github.event_name == 'pull_request'
shell: Rscript {0}
run: lucode2:::isVersionUpdated()

- name: Checks
shell: Rscript {0}
run: |
Expand All @@ -56,6 +61,8 @@ jobs:
- name: Test coverage
shell: Rscript {0}
run: covr::codecov(quiet = FALSE)
run: |
nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps"))
if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE)
env:
NOT_CRAN: "true"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9019
rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'lpjmlstats: Statistical tools for LPJmL data analysis'
version: 0.1.7
date-released: '2024-04-25'
version: 0.2.0
date-released: '2024-05-13'
abstract: This package provides statistical tools for LPJmL data analysis to be used
for benchmarking LPJmL outputs.
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lpjmlstats
Title: Statistical tools for LPJmL data analysis
Version: 0.1.7
Version: 0.2.0
Authors@R: c(person("David","Hötten", email = "[email protected]", role = c("aut", "cre")),
person("Jannes","Breier", email = "[email protected]", role = c("aut")))
Description: This package provides statistical tools for LPJmL data analysis
Expand Down Expand Up @@ -38,4 +38,4 @@ Config/testthat/edition: 3
VignetteBuilder: knitr
Depends:
R (>= 3.5.0)
Date: 2024-04-25
Date: 2024-05-13
8 changes: 4 additions & 4 deletions R/benchmark.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ benchmark <-
list(
baseline_dir = baseline_dir,
under_test_dirs = under_test_dirs,
suffix = ".bin.json"
suffix = getOption("lpjmlstats.file_extension", default = ".bin.json")
)

sim_table <- create_simulation_table(paths)
Expand Down Expand Up @@ -285,11 +285,11 @@ create_simulation_table <- function(paths) {
lpjml_version <- c()

for (path in sim_paths) {
# read any file with a .bin.json extension in the directory
# read any file with the correct file extension in the directory
# and extract the meta data

# get filename of any file with .bin.json extension in the directory
file <- list.files(path, pattern = ".bin.json", full.names = TRUE)[1]
# get filename of any fitting file
file <- list.files(path, pattern = paths$suffix, full.names = TRUE)[1]

# get relevant meta information from that file
meta <- lpjmlkit::read_meta(file)
Expand Down
8 changes: 8 additions & 0 deletions R/package_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#' \item \code{metric_at_start}: A string to be matched against the
#' names of the metrics. The matched metrics will be run first
#' and displayed at the beginning of the report.
#'
#' \item \code{file_extension}: A string indicating the file extension
#' to be used by read_io.
#' }
#'
#'
Expand Down Expand Up @@ -76,6 +79,11 @@ set_lpjmlstats_settings <- function(...) {
stop("metrics_at_start must be a character string")
options(lpjmlstats.metrics_at_start = option_value) # nolint
},
"file_extension" = {
if (!(is.character(option_value) | is.null(option_value)) | length(option_value) != 1)
stop("file_extension must be a character string")
options(lpjmlstats.file_extension = option_value) # nolint
},
stop(paste("Invalid option:", option_name))
)
}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Statistical tools for LPJmL data analysis

R package **lpjmlstats**, version **0.1.7**
R package **lpjmlstats**, version **0.2.0**

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

## Purpose and Functionality

Expand Down Expand Up @@ -48,7 +48,7 @@ In case of questions / problems please contact David Hötten <davidho@pik-potsda

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

Hötten D, Breier J (2024). _lpjmlstats: Statistical tools for LPJmL data analysis_. R package version 0.1.7.
Hötten D, Breier J (2024). _lpjmlstats: Statistical tools for LPJmL data analysis_. R package version 0.2.0.

A BibTeX entry for LaTeX users is

Expand All @@ -57,6 +57,6 @@ A BibTeX entry for LaTeX users is
title = {lpjmlstats: Statistical tools for LPJmL data analysis},
author = {David Hötten and Jannes Breier},
year = {2024},
note = {R package version 0.1.7},
note = {R package version 0.2.0},
}
```
3 changes: 3 additions & 0 deletions man/set_lpjmlstats_settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cffb000

Please sign in to comment.