Skip to content

Commit

Permalink
Remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
doccstat committed May 30, 2024
1 parent eeca55f commit 1f23c07
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
28 changes: 12 additions & 16 deletions man/fastcpd_meanvariance.Rd

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

6 changes: 3 additions & 3 deletions src/fastcpd_class_nll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ CostResult Fastcpd::get_nll_pelt_lasso(
deviance = stats["deviance"];
List out = cv_glmnet(
data_segment.cols(1, data_segment.n_cols - 1),
data_segment.col(0), // # nocov
data_segment.col(0),
Named("family") = "gaussian"
);
colvec index_vec = as<colvec>(out["index"]),
Expand Down Expand Up @@ -497,7 +497,7 @@ CostResult Fastcpd::get_nll_pelt_mean(
}
const unsigned int segment_length = segment_end - segment_start + 1;
return {
{zeros<colvec>(p)}, // # nocov
{zeros<colvec>(p)},
{zeros<mat>(segment_length, p)},
std::log(2.0 * M_PI) * data_n_cols + log_det_sympd(variance_estimate) *
(segment_length) / 2.0 + (
Expand Down Expand Up @@ -546,7 +546,7 @@ CostResult Fastcpd::get_nll_pelt_meanvariance(
}

return {
{zeros<colvec>(p)}, // # nocov
{zeros<colvec>(p)},
{mat()},
(d * std::log(2.0 * M_PI) + d + log(det_value)) * segment_length / 2.0
};
Expand Down
28 changes: 12 additions & 16 deletions tests/testthat/examples/fastcpd_meanvariance_1.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
if (requireNamespace("mvtnorm", quietly = TRUE)) {
set.seed(1)
p <- 1
result <- fastcpd.mv(
rbind(
mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(1, p)),
mvtnorm::rmvnorm(400, mean = rep(10, p), sigma = diag(1, p)),
mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(100, p)),
mvtnorm::rmvnorm(300, mean = rep(0, p), sigma = diag(1, p)),
mvtnorm::rmvnorm(400, mean = rep(10, p), sigma = diag(1, p)),
mvtnorm::rmvnorm(300, mean = rep(10, p), sigma = diag(100, p))
)
)
summary(result)
plot(result)
}
set.seed(1)
p <- 1
result <- fastcpd.meanvariance(c(
rnorm(300, 0, 1),
rnorm(400, 10, 1),
rnorm(300, 0, 10),
rnorm(300, 0, 1),
rnorm(400, 10, 1),
rnorm(300, 10, 10)
))
summary(result)
plot(result)
2 changes: 0 additions & 2 deletions tests/testthat/test-examples-fastcpd_meanvariance_1.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
testthat::test_that(
"examples/fastcpd_meanvariance_1.R", {
testthat::skip_if_not_installed("mvtnorm")

source("examples/fastcpd_meanvariance_1.R")
testthat::expect_equal(result@cp_set, c(300, 700, 1001, 1300, 1700))
}
Expand Down

0 comments on commit 1f23c07

Please sign in to comment.