Skip to content

Commit

Permalink
Fix na.rm functionality for ncol<2
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan committed Mar 11, 2024
1 parent 3ff33d8 commit 14bc635
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions R/Methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ setMethod("Summary",
dimnames = list(colnames(n), c("median", "lower", "upper"))
)
HPD[, 1] <- colMedians(n, na.rm = na.rm)
ind_not_na <- !is.na(HPD[, 1])
HPD[ind_not_na, 2:3] <- apply(n[, ind_not_na], 2, function(col) {
HPD[, 2:3] <- apply(n, 2, function(col) {
if (na.rm) {
col <- na.omit(col)
}
Expand Down
2 changes: 1 addition & 1 deletion man/Summary-BASiCS_Chain-method.Rd

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

2 changes: 2 additions & 0 deletions tests/testthat/test_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test_that("Summary na.rm", {
expect_false(any(is.na(s1@parameters$nu)))
expect_true(all(is.na(s2@parameters$nu[1, ])))
expect_true(all(is.na(s2@parameters$nu[4, ])))
ChainSC@parameters$nu[1, 1:ncol(ChainSC@parameters$nu)] <- NA
expect_error(s3 <- Summary(ChainSC, na.rm = TRUE))
})

test_that("subset", {
Expand Down

0 comments on commit 14bc635

Please sign in to comment.