From ab8cbd6c6bab2be60b7927d235b368f479486eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:12 +0300 Subject: [PATCH 01/10] Use testthat 3 ed. locally --- R/DEPRECATED-read.mat.Witec.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/DEPRECATED-read.mat.Witec.R b/R/DEPRECATED-read.mat.Witec.R index 7eec132e..7402e589 100644 --- a/R/DEPRECATED-read.mat.Witec.R +++ b/R/DEPRECATED-read.mat.Witec.R @@ -52,13 +52,13 @@ read.mat.Witec <- function(file = stop("filename or connection needed")) { } hySpc.testthat::test(read.mat.Witec) <- function() { - context("read.mat.Witec") - test_that( - "deprecated", + test_that("deprecated", { + local_edition(3) + expect_warning( expect_error(read.mat.Witec(file = ""), "Can only read a MAT file"), "deprecated|supports" ) - ) + }) } From 0285d9501e5dda9bbebb9c044c44de8760767cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:15 +0300 Subject: [PATCH 02/10] Update DEPRECATED-read.spc.R --- R/DEPRECATED-read.spc.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/DEPRECATED-read.spc.R b/R/DEPRECATED-read.spc.R index 2600832a..08d672d5 100644 --- a/R/DEPRECATED-read.spc.R +++ b/R/DEPRECATED-read.spc.R @@ -850,15 +850,15 @@ read.spc <- function(filename, hySpc.testthat::test(read.spc) <- function() { - context("read.spc") - test_that( - "deprecated", + test_that("deprecated", { + local_edition(3) + expect_warning( expect_error(read.spc(file = ""), "can only read"), "deprecated" ) - ) + }) } From cdd9afb2b70214512da58a239ac3ac8f8c51ac29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:18 +0300 Subject: [PATCH 03/10] Update DEPRECATED-read.spe.R --- R/DEPRECATED-read.spe.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/DEPRECATED-read.spe.R b/R/DEPRECATED-read.spe.R index 20ca1d0f..2fe09895 100644 --- a/R/DEPRECATED-read.spe.R +++ b/R/DEPRECATED-read.spe.R @@ -358,11 +358,13 @@ spe.showcalpoints <- function(filename, xaxis = "file", acc2avg = F, cts_sec = F ############# UNIT TESTS ################ hySpc.testthat::test(read.spe) <- function() { - test_that( - "deprecated", + + test_that("deprecated", { + local_edition(3) + expect_warning( expect_error(read.spe(filename = ""), "can only read"), "deprecated" ) - ) + }) } From 6c172db42769f795f49193484b786d6618d411e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:22 +0300 Subject: [PATCH 04/10] Update DEPRECATED-read.txt.Renishaw.R --- R/DEPRECATED-read.txt.Renishaw.R | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/R/DEPRECATED-read.txt.Renishaw.R b/R/DEPRECATED-read.txt.Renishaw.R index 3746e004..7e2af42d 100644 --- a/R/DEPRECATED-read.txt.Renishaw.R +++ b/R/DEPRECATED-read.txt.Renishaw.R @@ -167,15 +167,14 @@ read.txt.Renishaw <- function(file = stop("file is required"), } hySpc.testthat::test(read.txt.Renishaw) <- function() { - context("read.txt.Renishaw") + local_edition(3) - test_that( - "deprecated", + test_that("deprecated", { expect_warning( expect_error(read.txt.Renishaw(file = ""), "cannot open"), "deprecated" ) - ) + }) } #' @rdname DEPRECATED-read.txt.Renishaw @@ -194,13 +193,13 @@ read.zip.Renishaw <- function(file = stop("filename is required"), } hySpc.testthat::test(read.zip.Renishaw) <- function() { - context("read.zip.Renishaw") - test_that( - "deprecated", + test_that("deprecated", { + local_edition(3) + expect_warning( expect_error(read.zip.Renishaw(file = ""), "cannot open"), "deprecated" ) - ) + }) } From 1cc615def4e448cd3ac83a7b828cd4545ea5b8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:27 +0300 Subject: [PATCH 05/10] Use testthat 3 ed. locally --- R/DEPRECATED-read.txt.Shimadzu.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/DEPRECATED-read.txt.Shimadzu.R b/R/DEPRECATED-read.txt.Shimadzu.R index 7559f405..447f5a2e 100644 --- a/R/DEPRECATED-read.txt.Shimadzu.R +++ b/R/DEPRECATED-read.txt.Shimadzu.R @@ -227,13 +227,13 @@ read.txt.Shimadzu <- function(filename, encoding = "", quiet = TRUE) { } hySpc.testthat::test(read.txt.Shimadzu) <- function() { - context("read.txt.Shimadzu") - test_that( - "deprecated", + test_that("deprecated", { + local_edition(3) + expect_warning( expect_error(read.txt.Shimadzu(file = ""), "attempt to select"), "deprecated" ) - ) + }) } From 47cd169b626a2f089efa9e04d2a345d2a60242cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:33:32 +0300 Subject: [PATCH 06/10] Use testthat 3 ed. locally --- R/plot.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/plot.R b/R/plot.R index 6bc2134a..8c99b761 100644 --- a/R/plot.R +++ b/R/plot.R @@ -188,6 +188,7 @@ hySpc.testthat::test(.plot) <- function() { # vdiffr::manage_cases(package = "./hyperSpec") test_that("warnings and errors in plot()", { + local_edition(3) # Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expect_silent(hy_spectra <- generate_hy_spectra()) From 287dbb5f74681c028ba132c535d110a40ed30ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 20:45:09 +0300 Subject: [PATCH 07/10] Suppress warnings ... that are no longer suppressed by `testthat` 3 ed. --- R/DEPRECATED-read.spc.R | 8 ++++---- R/DEPRECATED-read.spe.R | 4 ++-- R/DEPRECATED-read.txt.Renishaw.R | 11 ++++++----- R/DEPRECATED-read.txt.Shimadzu.R | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/R/DEPRECATED-read.spc.R b/R/DEPRECATED-read.spc.R index 08d672d5..8757267c 100644 --- a/R/DEPRECATED-read.spc.R +++ b/R/DEPRECATED-read.spc.R @@ -854,10 +854,10 @@ hySpc.testthat::test(read.spc) <- function() { test_that("deprecated", { local_edition(3) - expect_warning( - expect_error(read.spc(file = ""), "can only read"), - "deprecated" - ) + expect_warning(expect_warning( + expect_error(read.spc(file = ""), "can only read"), + "deprecated" + )) }) } diff --git a/R/DEPRECATED-read.spe.R b/R/DEPRECATED-read.spe.R index 2fe09895..04b26d60 100644 --- a/R/DEPRECATED-read.spe.R +++ b/R/DEPRECATED-read.spe.R @@ -362,9 +362,9 @@ hySpc.testthat::test(read.spe) <- function() { test_that("deprecated", { local_edition(3) - expect_warning( + expect_warning(expect_warning( expect_error(read.spe(filename = ""), "can only read"), "deprecated" - ) + )) }) } diff --git a/R/DEPRECATED-read.txt.Renishaw.R b/R/DEPRECATED-read.txt.Renishaw.R index 7e2af42d..f21645ce 100644 --- a/R/DEPRECATED-read.txt.Renishaw.R +++ b/R/DEPRECATED-read.txt.Renishaw.R @@ -167,13 +167,14 @@ read.txt.Renishaw <- function(file = stop("file is required"), } hySpc.testthat::test(read.txt.Renishaw) <- function() { - local_edition(3) test_that("deprecated", { - expect_warning( + local_edition(3) + + expect_warning(expect_warning( expect_error(read.txt.Renishaw(file = ""), "cannot open"), "deprecated" - ) + )) }) } @@ -197,9 +198,9 @@ hySpc.testthat::test(read.zip.Renishaw) <- function() { test_that("deprecated", { local_edition(3) - expect_warning( + expect_warning(expect_warning(expect_warning( expect_error(read.zip.Renishaw(file = ""), "cannot open"), "deprecated" - ) + ))) }) } diff --git a/R/DEPRECATED-read.txt.Shimadzu.R b/R/DEPRECATED-read.txt.Shimadzu.R index 447f5a2e..aa6b66c0 100644 --- a/R/DEPRECATED-read.txt.Shimadzu.R +++ b/R/DEPRECATED-read.txt.Shimadzu.R @@ -231,9 +231,9 @@ hySpc.testthat::test(read.txt.Shimadzu) <- function() { test_that("deprecated", { local_edition(3) - expect_warning( + expect_warning(expect_warning( expect_error(read.txt.Shimadzu(file = ""), "attempt to select"), "deprecated" - ) + )) }) } From 85e327fd122cf7fed724f9aa7ab9cf8b9cea9c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 22:47:56 +0300 Subject: [PATCH 08/10] Update devel version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 02fb8e59..36fbe60f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Encoding: UTF-8 Type: Package Title: Work with Hyperspectral Data, i.e. Spectra + Meta Information (Spatial, Time, Concentration, ...) -Version: 0.100.0.9000 +Version: 0.100.0.9001 Date: 2021-07-15 Maintainer: Claudia Beleites Authors@R: c( From f26c953ac5c5a6d825eeca7fd2555cec4b8c22e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 22:48:08 +0300 Subject: [PATCH 09/10] Update style --- R/wl_convert_units.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/wl_convert_units.R b/R/wl_convert_units.R index 8a00e09c..c4ce7761 100644 --- a/R/wl_convert_units.R +++ b/R/wl_convert_units.R @@ -8,11 +8,13 @@ #' @param from source unit #' @param to destination unit #' @param ref_wl laser wavelength (required for work with Raman shift) +#' #' @author R. Kiselev -#' @export #' #' @concept wavelengths #' +#' @export +#' #' @examples #' wl_convert_units(3200, "Raman shift", "nm", ref_wl = 785.04) #' wl_convert_units(785, "nm", "invcm") From 45fd2698f7eed7ac6400d5341b3b572cd8d55769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vilmantas=20G=C4=97g=C5=BEna?= Date: Tue, 3 Aug 2021 22:53:28 +0300 Subject: [PATCH 10/10] Allow `NULL` in `.wl_fix_unit_name()` --- R/wl_convert_units.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/wl_convert_units.R b/R/wl_convert_units.R index c4ce7761..42445eda 100644 --- a/R/wl_convert_units.R +++ b/R/wl_convert_units.R @@ -58,12 +58,20 @@ wl_raman2nm <- function(x, ref_wl) 1e7 / (1e7 / ref_wl - x) # Bring the argument to a conventional name -# FIXME: This function should be exported when `read.spe()` function is moved to -# another package. + # FIXME: This function should be documented. # Even if it used for internal purposes. +# #' @export -.wl_fix_unit_name <- function(unit) { +.wl_fix_unit_name <- function(unit, null_ok = FALSE) { + + # Allow NULL as the default value + if (isTRUE(null_ok)) { + if (is.null(unit)) { + return(unit) + } + } + unit <- gsub(" .*$", "", tolower(unit)) if (unit %in% c("raman", "stokes", "rel", "rel.", "relative", "rel.cm-1", "rel.cm", "rel.1/cm", "raman shift")) { return("raman")