From 7251040410c9fef00f0e107cec809cf2df7acb6b Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 12:07:39 +0200 Subject: [PATCH 01/12] Typos. --- R/Analyse_SAR.OSLdata.R | 2 +- R/RLum.Data.Curve-class.R | 6 +++--- R/RLum.Data.Image-class.R | 8 ++++---- R/Second2Gray.R | 2 +- R/apply_CosmicRayRemoval.R | 11 ++--------- R/calc_FuchsLang2001.R | 2 +- R/internals_RLum.R | 4 ++-- R/plot_RLum.Data.Curve.R | 2 +- R/read_BIN2R.R | 6 +++--- man/Analyse_SAR.OSLdata.Rd | 2 +- man/PSL2Risoe.BINfileData.Rd | 6 +++--- man/apply_CosmicRayRemoval.Rd | 2 +- man/calc_FuchsLang2001.Rd | 2 +- man/calc_Lamothe2003.Rd | 2 +- man/plot_RLum.Data.Curve.Rd | 6 +++--- man/scale_GammaDose.Rd | 4 ++-- man/write_R2BIN.Rd | 10 +++++----- 17 files changed, 35 insertions(+), 42 deletions(-) diff --git a/R/Analyse_SAR.OSLdata.R b/R/Analyse_SAR.OSLdata.R index 2076148d4..74fb65950 100644 --- a/R/Analyse_SAR.OSLdata.R +++ b/R/Analyse_SAR.OSLdata.R @@ -145,7 +145,7 @@ Analyse_SAR.OSLdata <- function( set, dtype, keep.SEL = FALSE, - info.measurement = "unkown measurement", + info.measurement = "unknown measurement", output.plot = FALSE, output.plot.single = FALSE, cex.global = 1, diff --git a/R/RLum.Data.Curve-class.R b/R/RLum.Data.Curve-class.R index 135f3d428..f3bfc0498 100644 --- a/R/RLum.Data.Curve-class.R +++ b/R/RLum.Data.Curve-class.R @@ -105,7 +105,7 @@ setAs("list", "RLum.Data.Curve", function(from,to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = NA_character_, data = matrix(unlist(from), ncol = 2), info = list()) @@ -124,7 +124,7 @@ setAs("data.frame", "RLum.Data.Curve", function(from,to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = NA_character_, data = as.matrix(from), info = list()) @@ -144,7 +144,7 @@ setAs("RLum.Data.Curve", "data.frame", setAs("matrix", "RLum.Data.Curve", function(from,to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = NA_character_, data = from, info = list()) diff --git a/R/RLum.Data.Image-class.R b/R/RLum.Data.Image-class.R index 64b005088..435692122 100644 --- a/R/RLum.Data.Image-class.R +++ b/R/RLum.Data.Image-class.R @@ -86,7 +86,7 @@ setClass( setAs("data.frame", "RLum.Data.Image", function(from,to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = "NA", data = array(unlist(from), dim = c(nrow(from),ncol(from),1)), info = list()) @@ -110,7 +110,7 @@ setAs("RLum.Data.Image", "data.frame", setAs("matrix", "RLum.Data.Image", function(from,to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = "NA", data = array(from, c(nrow(from), ncol(from), 1)), info = list()) @@ -131,7 +131,7 @@ setAs("RLum.Data.Image", "matrix", setAs("array", "RLum.Data.Image", function(from, to){ new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = "NA", data = from, info = list()) @@ -149,7 +149,7 @@ setAs("list", "RLum.Data.Image", array_list <- lapply(from, function(x) array(unlist(as.vector(x)), c(nrow(x), ncol(x), 1))) new(to, - recordType = "unkown curve type", + recordType = "unknown curve type", curveType = "NA", data = array(unlist(array_list), c(nrow(array_list[[1]]), ncol(array_list[[1]]), length(array_list))), diff --git a/R/Second2Gray.R b/R/Second2Gray.R index a6c36e84e..ddb24d156 100644 --- a/R/Second2Gray.R +++ b/R/Second2Gray.R @@ -135,7 +135,7 @@ Second2Gray <- function( if(dose.rate@originator != "calc_SourceDoseRate"){ - stop("[Second2Gray()] Wrong originator for dose.rate 'RLum.Results' object.") + stop("[Second2Gray()] Wrong originator for dose.rate 'RLum.Results' object.") }else{ diff --git a/R/apply_CosmicRayRemoval.R b/R/apply_CosmicRayRemoval.R index e49121ef2..74f9577d5 100644 --- a/R/apply_CosmicRayRemoval.R +++ b/R/apply_CosmicRayRemoval.R @@ -34,7 +34,7 @@ #' @param object [RLum.Data.Spectrum-class] or [RLum.Analysis-class] (**required**): input #' object to be treated. This can be also provided as [list]. If an [RLum.Analysis-class] object #' is provided, only the [RLum.Data.Spectrum-class] objects are treated. Please note: this mixing of -#' objects do not work for a list of `RLum.Data` objects. +#' objects does not work for a list of `RLum.Data` objects. #' #' @param method [character] (*with default*): #' Defines method that is applied for cosmic ray removal. Allowed methods are @@ -334,14 +334,7 @@ apply_CosmicRayRemoval <- function( mtext(side = 3, paste0("Frame: ", x, " (", colnames(object.data.temp)[x], ") - no threshold applied!")) - - - } - - - - } ##(9) - return information on the amount of removed cosmic-rays @@ -366,7 +359,7 @@ apply_CosmicRayRemoval <- function( }else{ - stop("[apply_CosmicRayRemoval()] Unkown method for cosmic ray removal.") + stop("[apply_CosmicRayRemoval()] Unknown method for cosmic ray removal.") } diff --git a/R/calc_FuchsLang2001.R b/R/calc_FuchsLang2001.R index 7018ace78..c0dff25a1 100644 --- a/R/calc_FuchsLang2001.R +++ b/R/calc_FuchsLang2001.R @@ -14,7 +14,7 @@ #' **Basic steps of the approach** #' #' 1. Estimate natural relative variation of the sample using a dose recovery test -#' 2. Sort the input values ascendantly +#' 2. Sort the input values in ascending order #' 3. Calculate a running mean, starting with the lowermost two values and add values iteratively. #' 4. Stop if the calculated `c[v]` exceeds the specified `cvThreshold` #' diff --git a/R/internals_RLum.R b/R/internals_RLum.R index e85607dbd..042264f79 100644 --- a/R/internals_RLum.R +++ b/R/internals_RLum.R @@ -114,9 +114,9 @@ #+ .smoothing() + #+++++++++++++++++++++ -#' Allows smmoothing of data based on the function zoo::rollmean +#' Allows smoothing of data based on the function zoo::rollmean #' -#' The function just allows a direct and meaningfull access to the functionality of the zoo::rollmean() +#' The function just allows a direct and meaningful access to the functionality of the zoo::rollmean() #' function. Arguments of the function are only partly valid. #' #' @param x [numeric] (**required**): diff --git a/R/plot_RLum.Data.Curve.R b/R/plot_RLum.Data.Curve.R index 719b4f0c9..8e7cc0ad7 100644 --- a/R/plot_RLum.Data.Curve.R +++ b/R/plot_RLum.Data.Curve.R @@ -23,7 +23,7 @@ #' y = (observed - median(background)) / (max(observed) - median(background)) #' } #' -#' The background of the curve is defined as the last 20 % of the count values +#' The background of the curve is defined as the last 20% of the count values #' of a curve. #' #' @param object [RLum.Data.Curve-class] (**required**): diff --git a/R/read_BIN2R.R b/R/read_BIN2R.R index 0620276ab..c437ede5d 100644 --- a/R/read_BIN2R.R +++ b/R/read_BIN2R.R @@ -808,7 +808,7 @@ read_BIN2R <- function( TIME_SIZE <- readBin(con, what="int", 1, size=1, endian="little") ##time size corrections for wrong time formats; set n to 6 for all values - ##according the handbook by Geoff Duller, 2007 + ##according to the handbook by Geoff Duller, 2007 if(length(TIME_SIZE)>0){ temp.TIME<-readChar(con, TIME_SIZE, useBytes=TRUE) @@ -831,7 +831,7 @@ read_BIN2R <- function( DATE_SIZE<-readBin(con, what="int", 1, size=1, endian="little") ##date size corrections for wrong date formats; set n to 6 for all values - ##according the handbook of Geoff Duller, 2007 + ##according to the handbook of Geoff Duller, 2007 DATE_SIZE<-6 temp.DATE <- suppressWarnings(readChar(con, DATE_SIZE, useBytes = TRUE)) @@ -1053,7 +1053,7 @@ read_BIN2R <- function( DATE_SIZE<-readBin(con, what="int", 1, size=1, endian="little") ##date size corrections for wrong date formats; set n to 6 for all values - ##according the handbook of Geoff Duller, 2007 + ##according to the handbook of Geoff Duller, 2007 DATE_SIZE<-6 temp.DATE<-readChar(con, DATE_SIZE, useBytes=TRUE) diff --git a/man/Analyse_SAR.OSLdata.Rd b/man/Analyse_SAR.OSLdata.Rd index 34e3dc72e..9117934a7 100644 --- a/man/Analyse_SAR.OSLdata.Rd +++ b/man/Analyse_SAR.OSLdata.Rd @@ -13,7 +13,7 @@ Analyse_SAR.OSLdata( set, dtype, keep.SEL = FALSE, - info.measurement = "unkown measurement", + info.measurement = "unknown measurement", output.plot = FALSE, output.plot.single = FALSE, cex.global = 1, diff --git a/man/PSL2Risoe.BINfileData.Rd b/man/PSL2Risoe.BINfileData.Rd index 7367440fc..b96335e9b 100644 --- a/man/PSL2Risoe.BINfileData.Rd +++ b/man/PSL2Risoe.BINfileData.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/PSL2Risoe.BINfileData.R \name{PSL2Risoe.BINfileData} \alias{PSL2Risoe.BINfileData} -\title{Convert portable OSL data to an Risoe.BINfileData object} +\title{Convert portable OSL data to a Risoe.BINfileData object} \usage{ PSL2Risoe.BINfileData(object, ...) } @@ -18,11 +18,11 @@ BIN file using \link{write_R2BIN}. } \description{ Converts an \code{RLum.Analysis} object produced by the function \code{read_PSL2R()} to -an \code{Risoe.BINfileData} object \strong{(BETA)}. +a \code{Risoe.BINfileData} object \strong{(BETA)}. } \details{ This function converts an \linkS4class{RLum.Analysis} object that was produced -by the \link{read_PSL2R} function to an \linkS4class{Risoe.BINfileData}. +by the \link{read_PSL2R} function to a \linkS4class{Risoe.BINfileData}. The \code{Risoe.BINfileData} can be used to write a Risoe BIN file via \link{write_R2BIN}. } diff --git a/man/apply_CosmicRayRemoval.Rd b/man/apply_CosmicRayRemoval.Rd index 4e92e4e64..13de2e2d7 100644 --- a/man/apply_CosmicRayRemoval.Rd +++ b/man/apply_CosmicRayRemoval.Rd @@ -19,7 +19,7 @@ apply_CosmicRayRemoval( \item{object}{\linkS4class{RLum.Data.Spectrum} or \linkS4class{RLum.Analysis} (\strong{required}): input object to be treated. This can be also provided as \link{list}. If an \linkS4class{RLum.Analysis} object is provided, only the \linkS4class{RLum.Data.Spectrum} objects are treated. Please note: this mixing of -objects do not work for a list of \code{RLum.Data} objects.} +objects does not work for a list of \code{RLum.Data} objects.} \item{method}{\link{character} (\emph{with default}): Defines method that is applied for cosmic ray removal. Allowed methods are diff --git a/man/calc_FuchsLang2001.Rd b/man/calc_FuchsLang2001.Rd index 96b061867..1270453a5 100644 --- a/man/calc_FuchsLang2001.Rd +++ b/man/calc_FuchsLang2001.Rd @@ -50,7 +50,7 @@ calculation (e.g. 2nd or 3rd value). \strong{Basic steps of the approach} \enumerate{ \item Estimate natural relative variation of the sample using a dose recovery test -\item Sort the input values ascendantly +\item Sort the input values in ascending order \item Calculate a running mean, starting with the lowermost two values and add values iteratively. \item Stop if the calculated \code{c[v]} exceeds the specified \code{cvThreshold} } diff --git a/man/calc_Lamothe2003.Rd b/man/calc_Lamothe2003.Rd index 102b5ac18..c615ddf68 100644 --- a/man/calc_Lamothe2003.Rd +++ b/man/calc_Lamothe2003.Rd @@ -73,7 +73,7 @@ The original function call } \description{ This function applies the fading correction for the prediction of long-term fading as suggested -by Lamothe et al., 2003. The function basically adjusts the $L_n/T_n$ values and fit a new dose-response +by Lamothe et al., 2003. The function basically adjusts the $L_n/T_n$ values and fits a new dose-response curve using the function \link{plot_GrowthCurve}. } \details{ diff --git a/man/plot_RLum.Data.Curve.Rd b/man/plot_RLum.Data.Curve.Rd index e7ca060e7..3db517930 100644 --- a/man/plot_RLum.Data.Curve.Rd +++ b/man/plot_RLum.Data.Curve.Rd @@ -38,12 +38,12 @@ The function provides a standardised plot output for curve data of an \code{RLum.Data.Curve} S4-class object. } \details{ -Only single curve data can be plotted with this function.Arguments +Only single curve data can be plotted with this function. Arguments according to \link{plot}. \strong{Curve normalisation} -The argument \code{norm} normalises all count values, to date the following +The argument \code{norm} normalises all count values. To date the following options are supported: \code{norm = TRUE} or \code{norm = "max"}: Curve values are normalised to the highest @@ -58,7 +58,7 @@ via GitHub: y = (observed - median(background)) / (max(observed) - median(background)) } -The background of the curve is defined as the last 20 \% of the count values +The background of the curve is defined as the last 20\% of the count values of a curve. } \note{ diff --git a/man/scale_GammaDose.Rd b/man/scale_GammaDose.Rd index deb22be13..4ad743e1a 100644 --- a/man/scale_GammaDose.Rd +++ b/man/scale_GammaDose.Rd @@ -120,7 +120,7 @@ received by the sample in the target layer. } \description{ This function calculates the gamma dose deposited in a luminescence sample -taking into account layer-to-layer variations in sediment radioactivity . +taking into account layer-to-layer variations in sediment radioactivity. The function scales user inputs of uranium, thorium and potassium based on input parameters for sediment density, water content and given layer thicknesses and distances to the sample. @@ -146,7 +146,7 @@ value must be provided, which is the distance (in cm) measured from \strong{bott of the layer of interest. If the whole layer was sampled insert \code{0}. If the sample was taken from \emph{within} the layer, insert a numerical value \verb{>0}, which describes the distance from the middle of the sample to the bottom of -the layer in cm. Columns 4 to 9 should contain radionuclide concentrations +the layer in cm. Columns 4 to 9 should contain radionuclide concentrations and their standard errors for potassium (in \%), thorium (in ppm) and uranium (in ppm). Columns 10 and 11 give information on the water content and its uncertainty (standard error) diff --git a/man/write_R2BIN.Rd b/man/write_R2BIN.Rd index 65bd4b8aa..761c509d6 100644 --- a/man/write_R2BIN.Rd +++ b/man/write_R2BIN.Rd @@ -24,7 +24,7 @@ file name and path of the output file }} \item{version}{\link{character} (\emph{optional}): -version number for the output file. If no value is provided the highest +version number for the output file. If no value is provided, the highest version number from the \linkS4class{Risoe.BINfileData} is taken automatically. \strong{Note:} @@ -35,7 +35,7 @@ this option recalculates the position values if necessary and set the max. value to 48. The old position number is appended as comment (e.g., 'OP: 70). This option accounts for potential compatibility problems with the Analyst software. It further limits the maximum number of points per curve to 9,999. If a curve contains more -data the curve data got binned using the smallest possible bin width.} +data the curve data get binned using the smallest possible bin width.} \item{txtProgressBar}{\link{logical} (\emph{with default}): enables or disables \link{txtProgressBar}.} @@ -65,10 +65,10 @@ chosen input and output data (e.g., conversion from version 08 to 07 to 06 to 05 \strong{Warning} -Although the coding was done carefully it seems that the BIN/BINX-files +Although the coding was done carefully, it seems that the BIN/BINX-files produced by Risø DA 15/20 TL/OSL readers slightly differ on the byte level. No obvious differences are observed in the METADATA, however, the -BIN/BINX-file may not fully compatible, at least not similar to the once +BIN/BINX-file may not fully compatible, at least not similar to the ones directly produced by the Risø readers! ROI definitions (introduced in BIN-file version 8) are not supported! @@ -79,7 +79,7 @@ There are furthermore ignored by the function \link{read_BIN2R}. } \examples{ -##load exampled dataset +##load example dataset file <- system.file("extdata/BINfile_V8.binx", package = "Luminescence") temp <- read_BIN2R(file) From d71135faf9502ac627b48c415998807c269039bc Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 09:20:53 +0200 Subject: [PATCH 02/12] Complete coverage for apply_CosmicRayRemoval.R. --- tests/testthat/test_apply_CosmicRayRemoval.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_apply_CosmicRayRemoval.R b/tests/testthat/test_apply_CosmicRayRemoval.R index 896e1b49f..cd8e7a4df 100644 --- a/tests/testthat/test_apply_CosmicRayRemoval.R +++ b/tests/testthat/test_apply_CosmicRayRemoval.R @@ -9,6 +9,8 @@ test_that("check function", { expect_error( apply_CosmicRayRemoval("error"), regexp = "An object of class 'character' is not supported as input; please read the manual!") + expect_error(apply_CosmicRayRemoval(TL.Spectrum, method = "error"), + "Unknown method for cosmic ray removal") ##run basic tests expect_silent(apply_CosmicRayRemoval(TL.Spectrum, method = "Pych")) @@ -17,6 +19,9 @@ test_that("check function", { expect_output(apply_CosmicRayRemoval(TL.Spectrum, method = "Pych", MARGIN = 2, verbose = TRUE, plot = TRUE)) expect_silent(apply_CosmicRayRemoval(TL.Spectrum, method = "Pych", method.Pych.smoothing = 2, method.Pych.threshold_factor = 2)) + expect_silent(apply_CosmicRayRemoval(TL.Spectrum, method = "smooth.spline", + kind = "3RS3R", twiceit = TRUE, + spar = NULL, MARGIN = 1)) ##construct objects for different tests RLum_list <- list(TL.Spectrum) @@ -33,6 +38,4 @@ test_that("check function", { expect_error(apply_CosmicRayRemoval(RLum_list_mixed)) expect_s4_class(apply_CosmicRayRemoval(RLum.Analysis_mixed), class = "RLum.Analysis") expect_type(apply_CosmicRayRemoval(RLum.Analysis_mixed_list), "list") - }) - From 331afaa79bbd88db79be24acfeeae5320181f061 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 10:05:10 +0200 Subject: [PATCH 03/12] Increase coverage in merge_Risoe.BINfileData.R. This also renames the test file to match the corresponding package file. --- R/merge_Risoe.BINfileData.R | 13 +++------ tests/testthat/test_merge_Risoe.BINfileData.R | 29 +++++++++++++++++++ tests/testthat/test_merge_RisoeBINfileData.R | 18 ------------ 3 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 tests/testthat/test_merge_Risoe.BINfileData.R delete mode 100644 tests/testthat/test_merge_RisoeBINfileData.R diff --git a/R/merge_Risoe.BINfileData.R b/R/merge_Risoe.BINfileData.R index 0da570d59..23e539fd0 100644 --- a/R/merge_Risoe.BINfileData.R +++ b/R/merge_Risoe.BINfileData.R @@ -87,7 +87,7 @@ merge_Risoe.BINfileData <- function( # Integrity Checks -------------------------------------------------------- if(length(input.objects) < 2){ - message("[merge_Risoe.BINfileData()] Nothing done at least two input objects are needed!") + message("[merge_Risoe.BINfileData()] Nothing done: at least two input objects are needed!") return(input.objects) } @@ -95,10 +95,9 @@ merge_Risoe.BINfileData <- function( if(is(input.objects, "character") == TRUE){ for(i in 1:length(input.objects)){ if(file.exists(input.objects[i])==FALSE){ - stop("[merge_Risoe.BINfileData()] File ",input.objects[i]," does not exist!", call. = FALSE) - + stop("[merge_Risoe.BINfileData()] File '", input.objects[i], + "' does not exist!", call. = FALSE) } - } }else{ @@ -114,12 +113,8 @@ merge_Risoe.BINfileData <- function( } }else{ - - stop("[merge_Risoe.BINfileData()] - Input object is not a 'character' nor a 'list'!") - + stop("[merge_Risoe.BINfileData()] Input object is neither a character nor a list!") } - } diff --git a/tests/testthat/test_merge_Risoe.BINfileData.R b/tests/testthat/test_merge_Risoe.BINfileData.R new file mode 100644 index 000000000..c20533f4f --- /dev/null +++ b/tests/testthat/test_merge_Risoe.BINfileData.R @@ -0,0 +1,29 @@ +test_that("Test merging", { + testthat::skip_on_cran() + local_edition(3) + + ##expect error + expect_error(merge_Risoe.BINfileData(input.objects = c("data", "data2")), + "File 'data' does not exist") + expect_error(merge_Risoe.BINfileData(input.objects = list("data", "data2")), + "Input list does not contain Risoe.BINfileData objects!") + expect_error(merge_Risoe.BINfileData(input.objects = c(FALSE, FALSE)), + "Input object is neither a character nor a list") + + ## nothing done + input <- "data" + expect_message(res <- merge_Risoe.BINfileData(input.objects = input), + "Nothing done: at least two input objects are needed") + expect_equal(res, input) + + ## expect success + data(ExampleData.BINfileData, envir = environment()) + object1 <- CWOSL.SAR.Data + object2 <- CWOSL.SAR.Data + expect_s4_class(merge_Risoe.BINfileData(c(object1, object2)), "Risoe.BINfileData") + + binx <- system.file("extdata/BINfile_V8.binx", package = "Luminescence") + output.file <- tempfile() + merge_Risoe.BINfileData(c(binx, binx), output.file) + expect_true(file.exists(output.file)) +}) diff --git a/tests/testthat/test_merge_RisoeBINfileData.R b/tests/testthat/test_merge_RisoeBINfileData.R deleted file mode 100644 index c1bdf1693..000000000 --- a/tests/testthat/test_merge_RisoeBINfileData.R +++ /dev/null @@ -1,18 +0,0 @@ -##Full check -test_that("Test merging", { - testthat::skip_on_cran() - local_edition(3) - - ##expect error - expect_message(merge_Risoe.BINfileData(input.objects = "data"), regexp = "\\[merge\\_Risoe\\.BINfileData\\(\\)\\] Nothing done.+") - expect_error(merge_Risoe.BINfileData(input.objects = c("data", "data2"))) - expect_error(merge_Risoe.BINfileData(input.objects = list("data", "data2")), regexp = "[merge_Risoe.BINfileData()] Input list does not contain Risoe.BINfileData objects!", fixed = TRUE) - - ##expect success - data(ExampleData.BINfileData, envir = environment()) - object1 <- CWOSL.SAR.Data - object2 <- CWOSL.SAR.Data - expect_s4_class(merge_Risoe.BINfileData(c(object1, object2)), "Risoe.BINfileData") - -}) - From 0110fedab1e095eba6455357699fdd98dff1b5e9 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 10:20:44 +0200 Subject: [PATCH 04/12] Complete coverage for calc_HomogeneityTest.R. --- tests/testthat/test_calc_HomogeneityTest.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_calc_HomogeneityTest.R b/tests/testthat/test_calc_HomogeneityTest.R index c21ec81cd..d7709878f 100755 --- a/tests/testthat/test_calc_HomogeneityTest.R +++ b/tests/testthat/test_calc_HomogeneityTest.R @@ -4,16 +4,22 @@ df <- x = c(30.1, 53.8, 54.3, 29.0, 47.6, 44.2, 43.1), y = c(4.8, 7.1, 6.8, 4.3, 5.2, 5.9, 3.0)) -temp <- calc_HomogeneityTest(df) +temp <- calc_HomogeneityTest(df, verbose = FALSE) test_that("check class and length of output", { testthat::skip_on_cran() local_edition(3) + expect_error(calc_HomogeneityTest(TRUE), + "'data' object has to be of type 'data.frame' or 'RLum.Results'") + expect_s4_class(temp, "RLum.Results") expect_equal(length(temp), 3) + ## using an RLum.Results object as input + expect_s4_class(calc_HomogeneityTest(temp), + "RLum.Results") }) test_that("check values from output example", { From e7af35de2280c9479bc7110dff18320b32563f5b Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 10:41:26 +0200 Subject: [PATCH 05/12] Complete coverage for calc_FuchsLang2001.R. --- tests/testthat/test_calc_FuchsLang2001.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_calc_FuchsLang2001.R b/tests/testthat/test_calc_FuchsLang2001.R index e91bc6169..1450e4414 100755 --- a/tests/testthat/test_calc_FuchsLang2001.R +++ b/tests/testthat/test_calc_FuchsLang2001.R @@ -30,6 +30,11 @@ test_that("check class and length of output", { expect_equal(get_RLum(temp)$de_weighted_err, 20.58) expect_equal(get_RLum(temp)$n.usedDeValues, 22) + ## using an RLum.Results object as input + expect_s4_class(calc_FuchsLang2001(data = temp, startDeValue = 24, + plot = FALSE), + "RLum.Results") + ##the check output output <- expect_s4_class( calc_FuchsLang2001( @@ -41,4 +46,3 @@ test_that("check class and length of output", { ), "RLum.Results") }) - From dabf0b0c366ed7e4b7e833a600abcafea6c81ec9 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 11:29:00 +0200 Subject: [PATCH 06/12] Complete coverage for analyse_Al2O3C_CrossTalk.R. --- R/analyse_Al2O3C_CrossTalk.R | 14 ++++++- .../testthat/test_analyse_Al2O3C_CrossTalk.R | 37 +++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/R/analyse_Al2O3C_CrossTalk.R b/R/analyse_Al2O3C_CrossTalk.R index 0bd84a461..0f9eb7330 100644 --- a/R/analyse_Al2O3C_CrossTalk.R +++ b/R/analyse_Al2O3C_CrossTalk.R @@ -121,6 +121,10 @@ analyse_Al2O3C_CrossTalk <- function( ##modify on request if(!is.null(method_control)){ + if (!is.list(method_control)) { + stop("[analyse_Al2O3C_CrossTalk()] 'method_control' is expected ", + "to be a list", call. = FALSE) + } method_control_settings <- modifyList(x = method_control_settings, val = method_control) } @@ -146,6 +150,14 @@ analyse_Al2O3C_CrossTalk <- function( ##check irradiation time correction if (!is.null(irradiation_time_correction)) { + + if (!is.numeric(irradiation_time_correction) && + !is(irradiation_time_correction, "RLum.Results")) { + stop("[analyse_Al2O3C_CrossTalk()] 'irradiation_time_correction' ", + "is expected to be a numeric value or an RLum.Results object", + call. = FALSE) + } + if (is(irradiation_time_correction, "RLum.Results")) { if (irradiation_time_correction@originator == "analyse_Al2O3C_ITC") { irradiation_time_correction <- get_RLum(irradiation_time_correction) @@ -164,9 +176,7 @@ analyse_Al2O3C_CrossTalk <- function( "[analyse_Al2O3C_CrossTalk()] The object provided for the argument 'irradiation_time_correction' was created by an unsupported function!", call. = FALSE ) - } - } } diff --git a/tests/testthat/test_analyse_Al2O3C_CrossTalk.R b/tests/testthat/test_analyse_Al2O3C_CrossTalk.R index 40567397e..a1578cad3 100644 --- a/tests/testthat/test_analyse_Al2O3C_CrossTalk.R +++ b/tests/testthat/test_analyse_Al2O3C_CrossTalk.R @@ -1,4 +1,3 @@ -##Full check test_that("Full check", { skip_on_cran() local_edition(3) @@ -6,8 +5,38 @@ test_that("Full check", { ##load data data(ExampleData.Al2O3C, envir = environment()) - ##run analysis - expect_s4_class(analyse_Al2O3C_CrossTalk(data_CrossTalk), "RLum.Results") + ## run analysis + expect_s4_class(analyse_Al2O3C_CrossTalk(data_CrossTalk), "RLum.Results") + res <- expect_s4_class( + analyse_Al2O3C_CrossTalk(data_CrossTalk, + method_control = list(fit.method = "LIN")), + "RLum.Results") -}) + ## input validation + expect_error(analyse_Al2O3C_CrossTalk("test"), + "The elements in 'object' are not all of type 'RLum.Analsyis'") + expect_error(analyse_Al2O3C_CrossTalk(data_CrossTalk, + method_control = "EXP"), + "'method_control' is expected to be a list") + expect_error(analyse_Al2O3C_CrossTalk(data_CrossTalk, + irradiation_time_correction = FALSE), + "'irradiation_time_correction' is expected to be") + expect_error(analyse_Al2O3C_CrossTalk(data_CrossTalk, + irradiation_time_correction = res), + "was created by an unsupported function") + expect_warning(analyse_Al2O3C_CrossTalk(data_CrossTalk, + signal_integral = 0), + "Input for 'signal_integral' corrected to") + ## irradiation_time_correction + corr <- analyse_Al2O3C_ITC(data_ITC) + expect_s4_class( + analyse_Al2O3C_CrossTalk(data_CrossTalk, + irradiation_time_correction = corr), + "RLum.Results") + corr@data$data <- rbind(corr@data$data, corr@data$data) + expect_s4_class( + analyse_Al2O3C_CrossTalk(data_CrossTalk, + irradiation_time_correction = corr), + "RLum.Results") +}) From aac832ac621cdfdcebb95cf7a94684ce18b1831c Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 12:06:55 +0200 Subject: [PATCH 07/12] Increase coverage in Second2Gray.R. --- tests/testthat/test_Second2Gray.R | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/testthat/test_Second2Gray.R b/tests/testthat/test_Second2Gray.R index be1153841..16e54438e 100644 --- a/tests/testthat/test_Second2Gray.R +++ b/tests/testthat/test_Second2Gray.R @@ -2,12 +2,33 @@ data(ExampleData.DeValues, envir = environment()) results <- Second2Gray(ExampleData.DeValues$BT998, c(0.2,0.01)) results_alt1 <- Second2Gray(ExampleData.DeValues$BT998, c(0.2,0.01), error.propagation = "gaussian") results_alt2 <- Second2Gray(ExampleData.DeValues$BT998, c(0.2,0.01), error.propagation = "absolute") +dose.rate <- calc_SourceDoseRate(calib.date = "2014-12-19", + calib.dose.rate = 0.2, calib.error = 0.01) +results_alt3 <- Second2Gray(ExampleData.DeValues$BT998, dose.rate = dose.rate) + +Second2Gray(ExampleData.DeValues$BT998, results, error.prop = "gaussian") +Second2Gray(ExampleData.DeValues$BT998, results, error.prop = "absolute") + test_that("check class and length of output", { testthat::skip_on_cran() local_edition(3) expect_s3_class(results, class = "data.frame") + expect_error(Second2Gray("test"), + "'data' object has to be of type 'data.frame'") + expect_error(Second2Gray(ExampleData.DeValues$BT998, dose.rate = FALSE), + "'dose.rate' object has to be of type") + expect_error(Second2Gray(ExampleData.DeValues$BT998, + dose.rate = results[1:5, ]), + "'data' and 'dose.rate' need to be of similar length") + expect_error(Second2Gray(ExampleData.DeValues$BT998, + dose.rate = results, + error.propagation = "test"), + "unsupported error propagation method") + dose.rate@originator <- "unexpected-originator" + expect_error(Second2Gray(ExampleData.DeValues$BT998, dose.rate = dose.rate), + "Wrong originator for dose.rate 'RLum.Results' object") }) test_that("check values from output example", { From f02c2a5a3d3c58659471f1c1dd252f5078ece3ea Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 13:03:26 +0200 Subject: [PATCH 08/12] Increase coverage in analyse_SAR.CWOSL.R. This also renames the test file to match the corresponding package file. --- .../{test_analyse_SARCWOSL.R => test_analyse_SAR.CWOSL.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/testthat/{test_analyse_SARCWOSL.R => test_analyse_SAR.CWOSL.R} (100%) diff --git a/tests/testthat/test_analyse_SARCWOSL.R b/tests/testthat/test_analyse_SAR.CWOSL.R similarity index 100% rename from tests/testthat/test_analyse_SARCWOSL.R rename to tests/testthat/test_analyse_SAR.CWOSL.R From 05ee6d33fbe34f594c44a2476d271181fd46eeb7 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 14:47:07 +0200 Subject: [PATCH 09/12] Increase coverage in analyse_SAR.TL.R. This also renames the test file to match the corresponding package file. --- R/analyse_SAR.TL.R | 27 ++++-------- tests/testthat/test_analyse_SAR.TL.R | 64 ++++++++++++++++++++++++++++ tests/testthat/test_analyse_SARTL.R | 25 ----------- 3 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 tests/testthat/test_analyse_SAR.TL.R delete mode 100644 tests/testthat/test_analyse_SARTL.R diff --git a/R/analyse_SAR.TL.R b/R/analyse_SAR.TL.R index f722e53ff..4b56306c6 100644 --- a/R/analyse_SAR.TL.R +++ b/R/analyse_SAR.TL.R @@ -121,11 +121,14 @@ analyse_SAR.TL <- function( ... ){ + if (missing("object")) { + stop("[analyse_SAR.TL()] No value set for 'object'!", call. = FALSE) + } # Self-call ----------------------------------------------------------------------------------- if(inherits(object, "list")){ if(!all(sapply(object, class) == "RLum.Analysis")) - stop("[analyse_SAR.TL()] All elements in the input list need to be of class 'RLum.Analysis'!", + stop("[analyse_SAR.TL()] All elements in the input list must be of class 'RLum.Analysis'!", call. = FALSE) ##run sequence @@ -160,13 +163,7 @@ analyse_SAR.TL <- function( ##=============================================================================# # General Integrity Checks --------------------------------------------------- - ##GENERAL - ##MISSING INPUT - if(missing("object")==TRUE){ - stop("[analyse_SAR.TL()] No value set for 'object'!", call. = FALSE) - } - if(missing("signal.integral.min") == TRUE){ stop("[analyse_SAR.TL()] No value set for 'signal.integral.min'!", call. = FALSE) } @@ -321,9 +318,7 @@ analyse_SAR.TL <- function( LnLxTnTx[,"Name"]<-as.character(LnLxTnTx[,"Name"]) # Calculate Recycling Ratio ----------------------------------------------- - - ##Calculate Recycling Ratio - + RecyclingRatio <- NA if(length(LnLxTnTx[LnLxTnTx[,"Repeated"]==TRUE,"Repeated"])>0){ ##identify repeated doses @@ -351,19 +346,14 @@ analyse_SAR.TL <- function( ##Just transform the matrix and add column names RecyclingRatio<-t(RecyclingRatio) colnames(RecyclingRatio)<-temp.ColNames - - }else{RecyclingRatio<-NA} - + } # Calculate Recuperation Rate --------------------------------------------- - - - ##Recuperation Rate + Recuperation <- NA if("R0" %in% LnLxTnTx[,"Name"]==TRUE){ Recuperation<-round(LnLxTnTx[LnLxTnTx[,"Name"]=="R0","LxTx"]/ LnLxTnTx[LnLxTnTx[,"Name"]=="Natural","LxTx"],digits=4) - }else{Recuperation<-NA} - + } # Combine and Evaluate Rejection Criteria --------------------------------- @@ -702,4 +692,3 @@ analyse_SAR.TL <- function( return(newRLumResults.analyse_SAR.TL) } - diff --git a/tests/testthat/test_analyse_SAR.TL.R b/tests/testthat/test_analyse_SAR.TL.R new file mode 100644 index 000000000..18a500921 --- /dev/null +++ b/tests/testthat/test_analyse_SAR.TL.R @@ -0,0 +1,64 @@ +## load data +data(ExampleData.BINfileData, envir = environment()) + +## transform the values from the first position in a RLum.Analysis object +object <- Risoe.BINfileData2RLum.Analysis(TL.SAR.Data, pos = 3) + +test_that("Input validation", { + skip_on_cran() + local_edition(3) + + expect_error(analyse_SAR.TL(), + "No value set for 'object'") + expect_error(analyse_SAR.TL(object), + "No value set for 'signal.integral.min'") + expect_error(analyse_SAR.TL(object, signal.integral.min = 1), + "No value set for 'signal.integral.max'") + expect_error(analyse_SAR.TL("test", signal.integral.min = 1, + signal.integral.max = 2), + "Input object is not of type 'RLum.Analyis'") + expect_error(analyse_SAR.TL(list(object, "test")), + "elements in the input list must be of class 'RLum.Analysis'") + expect_error(analyse_SAR.TL(object, signal.integral.min = 1, + signal.integral.max = 2), + "Input TL curves are not a multiple of the sequence structure") +}) + +test_that("Test examples", { + skip_on_cran() + local_edition(3) + + ##perform analysis + expect_s4_class( + analyse_SAR.TL( + object, + signal.integral.min = 210, + signal.integral.max = 220, + fit.method = "EXP OR LIN", + sequence.structure = c("SIGNAL", "BACKGROUND") + ), + "RLum.Results" + ) + + expect_s4_class( + analyse_SAR.TL( + list(object, object), + signal.integral.min = 210, + signal.integral.max = 220, + dose.points = 1:7, + integral_input = "temperature", + sequence.structure = c("SIGNAL", "BACKGROUND")), + "RLum.Results" + ) + + expect_warning( + analyse_SAR.TL( + list(object), + signal.integral.min = 210, + signal.integral.max = 220, + dose.points = 1:7, + log = "x", + sequence.structure = c("SIGNAL", "BACKGROUND")), + "log-scale needs positive values; log-scale disabled" + ) +}) diff --git a/tests/testthat/test_analyse_SARTL.R b/tests/testthat/test_analyse_SARTL.R deleted file mode 100644 index 1d97baff2..000000000 --- a/tests/testthat/test_analyse_SARTL.R +++ /dev/null @@ -1,25 +0,0 @@ -##Full check -test_that("Test examples", { - skip_on_cran() - local_edition(3) - - ##load data - data(ExampleData.BINfileData, envir = environment()) - - ##transform the values from the first position in a RLum.Analysis object - object <- Risoe.BINfileData2RLum.Analysis(TL.SAR.Data, pos=3) - - ##perform analysis - expect_s4_class( - analyse_SAR.TL( - object, - signal.integral.min = 210, - signal.integral.max = 220, - fit.method = "EXP OR LIN", - sequence.structure = c("SIGNAL", "BACKGROUND") - ), - "RLum.Results" - ) - -}) - From dac9624368397f8bbba50624dec88c17f7db35fa Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 15:33:46 +0200 Subject: [PATCH 10/12] Complete coverage for calc_FadingCorr.R. --- R/calc_FadingCorr.R | 13 +++++-------- tests/testthat/test_calc_FadingCorr.R | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/R/calc_FadingCorr.R b/R/calc_FadingCorr.R index 36689609d..f6b64209f 100644 --- a/R/calc_FadingCorr.R +++ b/R/calc_FadingCorr.R @@ -220,11 +220,8 @@ calc_FadingCorr <- function( g_value <- as.numeric(get_RLum(g_value)[,c("FIT", "SD")]) }else{ - try({ - stop("[calc_FadingCorr()] Unknown originator for the provided RLum.Results object via 'g_value'!", - call. = FALSE) - - }) + message("[calc_FadingCorr()] Error: Unknown originator for the ", + "provided RLum.Results object via 'g_value'!") return(NULL) } } @@ -350,11 +347,11 @@ calc_FadingCorr <- function( ##otherwise the automatic error value finding ##will never work + res <- NA if(!is(temp,"try-error") && temp$root<1e8) { - return(temp$root) - } else{ - return(NA) + res <- temp$root } + return(res) }, FUN.VALUE = 1)) diff --git a/tests/testthat/test_calc_FadingCorr.R b/tests/testthat/test_calc_FadingCorr.R index b81b29a3e..12afc1c66 100644 --- a/tests/testthat/test_calc_FadingCorr.R +++ b/tests/testthat/test_calc_FadingCorr.R @@ -38,6 +38,26 @@ test_that("check class and length of output", { tc.g_value = 172800, n.MC = 1, verbose = TRUE), class = "RLum.Results") + ## g_value provided as RLum.Results object + data("ExampleData.Fading", envir = environment()) + fading <- analyse_FadingMeasurement(ExampleData.Fading$fading.data$IR50, + plot = FALSE) + expect_s4_class(calc_FadingCorr(age.faded = c(0.1,0), + g_value = fading, tc = 2592000), + "RLum.Results") + fading@originator <- "unexpected" + expect_message( + expect_null(calc_FadingCorr(age.faded = c(0.1,0), + g_value = fading, tc = 2592000)), + "Unknown originator for the provided RLum.Results object") + + ## auto, seed (Note: this is slow!) + calc_FadingCorr( + age.faded = c(0.1,0), + g_value = c(5.0, 1.0), + tc = 2592000, + seed = 1, + n.MC = "auto") }) test_that("check values from output example 1", { From b209ff95e08b4df7e61ac0418fc3dd1b802fede4 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 16:05:19 +0200 Subject: [PATCH 11/12] Increase coverage in calc_CosmicDoseRate.R. --- R/calc_CosmicDoseRate.R | 13 ++++---- tests/testthat/test_calc_CosmicDoseRate.R | 39 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/R/calc_CosmicDoseRate.R b/R/calc_CosmicDoseRate.R index a247806cd..ece95476c 100644 --- a/R/calc_CosmicDoseRate.R +++ b/R/calc_CosmicDoseRate.R @@ -260,19 +260,18 @@ calc_CosmicDoseRate<- function( ##============================================================================## if(any(depth < 0) || any(density < 0)) { - cat(paste("\nNo negative values allowed for depth and density")) - stop(domain=NA) + stop("[calc_CosmicDoseRate()] No negative values allowed for ", + "depth and density", call. = FALSE) } if(corr.fieldChanges == TRUE) { if(is.na(est.age) == TRUE) { - cat(paste("\nCorrection for geomagnetic field changes requires", - "an age estimate."), fill = FALSE) - stop(domain=NA) + stop("[calc_CosmicDoseRate()] Correction for geomagnetic field ", + "changes requires an age estimate.", call. = FALSE) } if(est.age > 80) { - cat(paste("\nCAUTION: No geomagnetic field change correction for samples", - "older >80 ka possible!"), fill = FALSE) + cat("\nCAUTION: No geomagnetic field change correction for samples", + "older >80 ka possible!") corr.fieldChanges<- FALSE } } diff --git a/tests/testthat/test_calc_CosmicDoseRate.R b/tests/testthat/test_calc_CosmicDoseRate.R index 014f93533..9ad0b94a9 100644 --- a/tests/testthat/test_calc_CosmicDoseRate.R +++ b/tests/testthat/test_calc_CosmicDoseRate.R @@ -3,6 +3,40 @@ temp <- calc_CosmicDoseRate(depth = 2.78, density = 1.7, altitude = 364, error = 10) +test_that("input validation", { + testthat::skip_on_cran() + local_edition(3) + + expect_error(calc_CosmicDoseRate(depth = -2), + "No negative values allowed for depth and density") + expect_error(calc_CosmicDoseRate(depth = 2.78, density = 1.7, + corr.fieldChanges = TRUE), + "requires an age estimate") + expect_error(calc_CosmicDoseRate(depth = 2.78, density = 1.7, + corr.fieldChanges = TRUE, est.age = 20, + latitude = 38.06451), + "is missing, with no default") + expect_error(calc_CosmicDoseRate(depth = 2.78, density = 1.7, + corr.fieldChanges = TRUE, est.age = 20, + latitude = 38.06451, longitude = 1.49646), + "is missing, with no default") + expect_error(calc_CosmicDoseRate(depth = 2.78, density = c(1.7, 2.9), + corr.fieldChanges = TRUE, est.age = 20, + latitude = 38.06451, longitude = 1.49646, + altitude = 364), + "If you provide more than one value for density") + expect_output(calc_CosmicDoseRate(depth = 2.78, density = 1.7, + corr.fieldChanges = TRUE, est.age = 100, + latitude = 38.0645, longitude = 1.4964, + altitude = 364), + "No geomagnetic field change correction for samples older >80 ka possible") + expect_output(calc_CosmicDoseRate(depth = 2.78, density = 1.7, + corr.fieldChanges = TRUE, est.age = 20, + latitude = 38.0645, longitude = 1.4964, + altitude = 364, half.depth = TRUE), + "No geomagnetic field change correction necessary for geomagnetic latitude >35 degrees") +}) + test_that("check class and length of output", { testthat::skip_on_cran() local_edition(3) @@ -10,6 +44,11 @@ test_that("check class and length of output", { expect_s4_class(temp, "RLum.Results") expect_equal(length(temp), 3) + ## length(depth) > length(density), half.depth + calc_CosmicDoseRate(depth = c(2.78, 3.12), density = 1.7, + corr.fieldChanges = TRUE, est.age = 20, + latitude = 28.06451, longitude = 1.49646, + altitude = 364, half.depth = TRUE) }) test_that("check values from output example 1", { From 475c5dcb28c58e04552cb3d44a115f34cecfa897 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Fri, 16 Aug 2024 16:45:24 +0200 Subject: [PATCH 12/12] Increase coverage in analyse_pIRIRSequence.R. --- R/analyse_pIRIRSequence.R | 36 +++++++++---------- tests/testthat/test_analyse_pIRIRSequence.R | 40 +++++++++++++++++++++ 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/R/analyse_pIRIRSequence.R b/R/analyse_pIRIRSequence.R index 3a431c5f6..646a0d723 100644 --- a/R/analyse_pIRIRSequence.R +++ b/R/analyse_pIRIRSequence.R @@ -180,6 +180,10 @@ analyse_pIRIRSequence <- function( ... ){ + if (missing("object")) { + stop("[analyse_pIRIRSequence()] No value set for 'object'!") + } + # SELF CALL ----------------------------------------------------------------------------------- if(is.list(object)){ @@ -267,14 +271,10 @@ analyse_pIRIRSequence <- function( ##GENERAL - ##MISSING INPUT - if(missing("object")==TRUE){ - stop("[analyse_pIRIRSequence()] No value set for 'object'!") - } - ##INPUT OBJECTS if(is(object, "RLum.Analysis")==FALSE){ - stop("[analyse_pIRIRSequence()] Input object is not of type 'RLum.Analyis'!") + stop("[analyse_pIRIRSequence()] Input object is not of type 'RLum.Analyis'!", + call. = FALSE) } ##CHECK ALLOWED VALUES IN SEQUENCE STRUCTURE @@ -293,20 +293,18 @@ analyse_pIRIRSequence <- function( # Deal with extra arguments ------------------------------------------------------------------- + ## default values + mtext.outer <- "MEASUREMENT INFO" + main <- "" + log <- "" + cex <- 0.7 + ##deal with addition arguments extraArgs <- list(...) - - mtext.outer <- if("mtext.outer" %in% names(extraArgs)) {extraArgs$mtext.outer} else - {"MEASUREMENT INFO"} - - main <- if("main" %in% names(extraArgs)) {extraArgs$main} else - {""} - - log <- if("log" %in% names(extraArgs)) {extraArgs$log} else - {""} - - cex <- if("cex" %in% names(extraArgs)) {extraArgs$cex} else - {.7} + mtext.outer <- if ("mtext.outer" %in% names(extraArgs)) extraArgs$mtext.outer + main <- if ("main" %in% names(extraArgs)) extraArgs$main + log <- if ("log" %in% names(extraArgs)) extraArgs$log + cex <- if ("cex" %in% names(extraArgs)) extraArgs$cex # Protocol Integrity Checks -------------------------------------------------- @@ -526,7 +524,7 @@ analyse_pIRIRSequence <- function( temp.signal.integral.min <- signal.integral.min[i] temp.signal.integral.max <- signal.integral.max[i] temp.background.integral.min <- background.integral.min[i] - temp.backbround.integral.max <- background.integral.max[i] + temp.background.integral.max <- background.integral.max[i] }else{ diff --git a/tests/testthat/test_analyse_pIRIRSequence.R b/tests/testthat/test_analyse_pIRIRSequence.R index 967536db1..5a00bf8c1 100644 --- a/tests/testthat/test_analyse_pIRIRSequence.R +++ b/tests/testthat/test_analyse_pIRIRSequence.R @@ -32,6 +32,46 @@ results <- analyse_pIRIRSequence( verbose = FALSE ) +## plot.single = FALSE && plot == TRUE +suppressWarnings( # warnings thrown by analyse_SAR.CWOSL and plot_GrowthCurve + analyse_pIRIRSequence( + object, + signal.integral.min = c(1, 2), + signal.integral.max = c(2, 3), + background.integral.min = 900, + background.integral.max = 1000, + fit.method = "EXP", + sequence.structure = c("TL", "pseudoIRSL1", "pseudoIRSL2"), + main = "Pseudo pIRIR data set based on quartz OSL", + plot = TRUE, + plot.single = FALSE, + verbose = FALSE + ) +) + +test_that("input validation", { + expect_error(analyse_pIRIRSequence(), + "No value set for 'object'") + expect_error(analyse_pIRIRSequence("test"), + "Input object is not of type 'RLum.Analyis'") + expect_error(analyse_pIRIRSequence(list("test"), + signal.integral.min = 1, + signal.integral.max = 2, + background.integral.min = 900, + background.integral.max = 1000), + "Input object is not of type 'RLum.Analyis'") + expect_warning(analyse_pIRIRSequence(list(object), + signal.integral.max = 2, + background.integral.min = 900, + background.integral.max = 1000), + "'signal.integral.min' missing, set to 1") + expect_warning(analyse_pIRIRSequence(list(object), + signal.integral.min = 1, + background.integral.min = 900, + background.integral.max = 1000), + "'signal.integral.max' missing, set to 2") +}) + test_that("check class and length of output", { testthat::skip_on_cran() local_edition(3)