Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show which filenames let as.quitte fail #100

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '626216492'
ValidationKey: '627240389'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
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: 'quitte: Bits and pieces of code to use with quitte-style data frames'
version: 0.3137.2
date-released: '2024-08-26'
version: 0.3137.3
date-released: '2024-09-27'
abstract: A collection of functions for easily dealing with quitte-style data frames,
doing multi-model comparisons and plots.
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: quitte
Title: Bits and pieces of code to use with quitte-style data frames
Version: 0.3137.2
Date: 2024-08-26
Version: 0.3137.3
Date: 2024-09-27
Authors@R: c(
person("Michaja", "Pehl", , "[email protected]", role = c("aut", "cre")),
person("Nico", "Bauer", , "[email protected]", role = "aut"),
Expand Down
10 changes: 5 additions & 5 deletions R/as.quitte.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ as.quitte <- function(x, periodClass = "integer", addNA = FALSE, na.rm = FALSE)

#' @export
as.quitte.character <- function(x, periodClass = "integer", addNA = FALSE, na.rm = FALSE) { # nolint
if (all(file.exists(x) & grepl("\\.(mif|csv|rds|xlsx?)$", x)))
welldefined <- file.exists(x) & grepl("\\.(mif|csv|rds|xlsx?)$", x)
if (all(welldefined))
return(as.quitte(read.quitte(x, sep = NULL),
periodClass = periodClass, addNA = addNA, na.rm = na.rm))
stop(
"Provided character cannot be converted to quitte as it does not seem to be a valid file path!"
)
stop("Provided character cannot be converted to quitte as those do not seem to be a valid file path: ",
paste(x[! welldefined], collapse = ", "))
}

#' @method as.quitte quitte
Expand Down Expand Up @@ -242,7 +242,7 @@ as.quitte.list <- function(x, periodClass = "integer", addNA = FALSE, na.rm = FA
#' @method as.quitte NULL
#' @export
as.quitte.NULL <- function(x, periodClass = "integer", addNA = FALSE, na.rm = FALSE) { # nolint
return(filter(as.quitte(as_tibble(as.quitte(data.frame(value = 0), periodClass = periodClass))), .data$value > 1))
return(droplevels(filter(as.quitte(as_tibble(as.quitte(data.frame(value = 0), periodClass = periodClass))), .data$value > 1)))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as.quitte(as_tibble(as.quitte()))
image

}

qaddNA <- function(x) {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bits and pieces of code to use with quitte-style data frames

R package **quitte**, version **0.3137.2**
R package **quitte**, version **0.3137.3**

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

Expand Down Expand Up @@ -47,7 +47,7 @@ In case of questions / problems please contact Michaja Pehl <michaja.pehl@pik-po

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

Pehl M, Bauer N, Hilaire J, Levesque A, Luderer G, Schultes A, Dietrich J, Richters O (2024). _quitte: Bits and pieces of code to use with quitte-style data frames_. R package version 0.3137.2, <https://github.com/pik-piam/quitte>.
Pehl M, Bauer N, Hilaire J, Levesque A, Luderer G, Schultes A, Dietrich J, Richters O (2024). _quitte: Bits and pieces of code to use with quitte-style data frames_. R package version 0.3137.3, <https://github.com/pik-piam/quitte>.

A BibTeX entry for LaTeX users is

Expand All @@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is
title = {quitte: Bits and pieces of code to use with quitte-style data frames},
author = {Michaja Pehl and Nico Bauer and Jérôme Hilaire and Antoine Levesque and Gunnar Luderer and Anselm Schultes and Jan Philipp Dietrich and Oliver Richters},
year = {2024},
note = {R package version 0.3137.2},
note = {R package version 0.3137.3},
url = {https://github.com/pik-piam/quitte},
}
```
9 changes: 9 additions & 0 deletions tests/testthat/test-as.quitte.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ test_that(
{
expect_true(is.quitte(as.quitte(NULL)))
expect_equal(nrow(as.quitte(NULL)), 0)
expect_equal(length(levels(as.quitte(NULL)$model)), 0)
}
)

test_that(
'as.quitte fails on non-supported filename',
{
expect_error(as.quitte('unknownfiletype.§§$%'),
'do not seem to be a valid file path: unknownfiletype.§§$%', fixed = TRUE)
}
)

Expand Down