Skip to content

Commit

Permalink
move sd.complex into sd.default because sd.matrix overrides sd.complex
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Nov 24, 2023
1 parent 3bab85c commit 31f82f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ S3method(rhat_basic,default)
S3method(rhat_basic,rvar)
S3method(rhat_nested,default)
S3method(rhat_nested,rvar)
S3method(sd,complex)
S3method(sd,default)
S3method(sd,rvar)
S3method(split_chains,draws)
Expand Down
13 changes: 8 additions & 5 deletions R/rvar-summaries-over-draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,14 @@ var.rvar <- variance.rvar
sd <- function(x, ...) UseMethod("sd")
#' @rdname rvar-summaries-over-draws
#' @export
sd.default <- function(x, ...) stats::sd(x, ...)
#' @rdname rvar-summaries-over-draws
#' @export
sd.complex <- function(x, ...) {
sqrt(variance(c(x), ...))
sd.default <- function(x, ...) {
# because complex matrices do not dispatch on the complex class, check for
# complex numbers here
if (is.complex(x)) {
sqrt(variance(c(x), ...))
} else {
stats::sd(x, ...)
}
}
#' @rdname rvar-summaries-over-draws
#' @export
Expand Down
3 changes: 0 additions & 3 deletions man/rvar-summaries-over-draws.Rd

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

0 comments on commit 31f82f8

Please sign in to comment.