Skip to content

Commit

Permalink
Don't leave the number of total aliquots empty in analyse_baSAR().
Browse files Browse the repository at this point in the history
If no aliquots are removed, removed_aliquots is NULL, and nrow() returns
integer(0): in such case tot.aliquots + nrow(removed_aliquots) is also
integer(0) and the output becomes the following:

   Number of aliquots used:	3/

instead of:

   Number of aliquots used:	3/3

So we need to perform that addition only if remove_aliquot is not NULL.
  • Loading branch information
mcol committed Mar 4, 2025
1 parent 97d535c commit 28d3e42
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
7 changes: 5 additions & 2 deletions NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ header-includes:

## Bugfixes

### `analyse_baSAR()`

* The number of aliquots used was only partially reported if no aliquots were
removed.

### `analyse_FadingMeasurement()`

* The function checks that an input object generated from an XSYG file
contains irradiation steps and returns an error if none are available,
instead of producing an unhelpful output (#588).

### `analyse_FadingMeasurement()`

* A regression in `plot_RLum.Analysis()` caused part of the plot of the
luminescence curves to be messed up (#589).

Expand Down
9 changes: 6 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- NEWS.md was auto-generated by NEWS.Rmd. Please DO NOT edit by hand!-->

# Changes in version 1.0.0.9000 (2025-02-28)
# Changes in version 1.0.0.9000 (2025-03-04)

## New functions

Expand All @@ -15,14 +15,17 @@

## Bugfixes

### `analyse_baSAR()`

- The number of aliquots used was only partially reported if no aliquots
were removed.

### `analyse_FadingMeasurement()`

- The function checks that an input object generated from an XSYG file
contains irradiation steps and returns an error if none are available,
instead of producing an unhelpful output (#588).

### `analyse_FadingMeasurement()`

- A regression in `plot_RLum.Analysis()` caused part of the plot of the
luminescence curves to be messed up (#589).

Expand Down
4 changes: 3 additions & 1 deletion R/analyse_baSAR.R
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,9 @@ analyse_baSAR <- function(
cat("------------------------------------------------------------------\n")
cat(paste0("Used distribution:\t\t", results[[1]][["DISTRIBUTION"]],"\n"))
num.aliquots <- results[[1]][["NB_ALIQUOTS"]]
tot.aliquots <- num.aliquots + nrow(removed_aliquots)
tot.aliquots <- num.aliquots
if (!is.null(removed_aliquots))
tot.aliquots <- tot.aliquots + nrow(removed_aliquots)
cat(paste0("Number of aliquots used:\t", num.aliquots, "/", tot.aliquots))
if (!is.null(aliquot_range)) {
cat(" (manually removed: ", length(aliquot_range), ")\n")
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test_analyse_baSAR.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@ test_that("Full check of analyse_baSAR function", {

## rerun with previous results as input
SW({
results2 <- analyse_baSAR(
object = results,
expect_output(results2 <- analyse_baSAR(
object = results,
plot = FALSE,
verbose = FALSE,
verbose = TRUE,
txtProgressBar = FALSE,
n.MCMC = 100)
n.MCMC = 100),
"Number of aliquots used:.+3/3")

expect_warning(analyse_baSAR(
object = results,
Expand Down

0 comments on commit 28d3e42

Please sign in to comment.