From 5f954366d177697a1813d59a43fa691ea97facd9 Mon Sep 17 00:00:00 2001 From: Rebecca Killick Date: Mon, 14 Oct 2024 05:11:02 +0100 Subject: [PATCH] Forgot to update the tests with the new values for pen.value.full and diagnostic plots. --- DESCRIPTION | 8 +- .../diagnostic-plot-default.svg | 76 ++-- .../diagnostic-plot-histogram.svg | 341 +++++++++--------- tests/testthat/Rplots.pdf | Bin 6951 -> 7139 bytes .../_snaps/plot/diagnostic-plot-default.svg | 59 +++ .../_snaps/plot/diagnostic-plot-histogram.svg | 192 ++++++++++ tests/testthat/test-examples.R | 6 +- tests/testthat/test-plot.R | 4 +- 8 files changed, 473 insertions(+), 213 deletions(-) create mode 100644 tests/testthat/_snaps/plot/diagnostic-plot-default.svg create mode 100644 tests/testthat/_snaps/plot/diagnostic-plot-histogram.svg diff --git a/DESCRIPTION b/DESCRIPTION index 2c8d60c..c2ee086 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: changepoint Type: Package Title: Methods for Changepoint Detection Version: 2.3 -Date: 2024-10-12 +Date: 2024-10-14 Authors@R: c(person("Rebecca", "Killick", role=c("aut","cre"),email="r.killick@lancs.ac.uk"), person("Kaylea", "Haynes", role="ctb"), @@ -18,10 +18,10 @@ Depends: R(>= 3.2), methods, stats, zoo(>= 0.9-1) Suggests: testthat, vdiffr License: GPL LazyData: true -Packaged: 2024-10-12 14:14:13 UTC; killick +Packaged: 2024-10-14 14:14:13 UTC; killick NeedsCompilation: yes Repository: CRAN -Date/Publication: 2024-10-12 15:50:02 UTC +Date/Publication: 2024-10-14 15:50:02 UTC Author: Rebecca Killick [aut, cre], Kaylea Haynes [ctb], Harjit Hullait [ctb], @@ -29,4 +29,4 @@ Author: Rebecca Killick [aut, cre], Paul Fearnhead [ctb, ths], Robin Long [ctb], Jamie Lee [ctr] - +RoxygenNote: 7.3.2 diff --git a/tests/figs/plot-diagnostic-true-tests/diagnostic-plot-default.svg b/tests/figs/plot-diagnostic-true-tests/diagnostic-plot-default.svg index 1ded7b3..4a60491 100644 --- a/tests/figs/plot-diagnostic-true-tests/diagnostic-plot-default.svg +++ b/tests/figs/plot-diagnostic-true-tests/diagnostic-plot-default.svg @@ -1,8 +1,8 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +100 +200 +300 +400 +500 + + + + + + +0 +50 +100 +150 +200 + +Penalty Value +Number of Changepoints + + diff --git a/tests/testthat/_snaps/plot/diagnostic-plot-histogram.svg b/tests/testthat/_snaps/plot/diagnostic-plot-histogram.svg new file mode 100644 index 0000000..fc4323e --- /dev/null +++ b/tests/testthat/_snaps/plot/diagnostic-plot-histogram.svg @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +100 +200 +300 +400 +500 + + + + + + +0 +50 +100 +150 +200 + +Penalty Value +Number of Changepoints + + diff --git a/tests/testthat/test-examples.R b/tests/testthat/test-examples.R index b111db6..ccc0eb0 100644 --- a/tests/testthat/test-examples.R +++ b/tests/testthat/test-examples.R @@ -48,7 +48,7 @@ truth=matrix(NA,ncol=7,nrow=7); truth[1:6,1]=50;truth[1:5,2]=c(96,96,100,100,150 truth[1:4,3]=c(100,100,133,150);truth[1:3,4]=c(133,133,150);truth[1:2,5]=c(150,150) truth[1,6]=159;truth[1,7]=180 test_that('crops1',expect_equivalent(cpts.full(out),truth)) -truth=c(4.000000, 4.332496, 4.385247, 4.684254 ,559.366988, 646.962719,1311.335695) +truth=c(4.000000, 4.332496, 4.385247, 4.684254 ,559.366988, 646.962719,1311.335695,1500.000000) test_that('crops2',expect_equal(pen.value.full(out),truth,tolerance=1e-6)) # Example multiple datasets where the first row has multiple changes in mean and the second row has @@ -89,7 +89,7 @@ truth=matrix(NA,ncol=9,nrow=6);truth[1:5,1]=c(rep(15,2),rep(50,3));truth[1:4,2]= truth[1:4,3]=c(22,22,133,150);truth[1:3,4]=c(44,50,151);truth[1:2,5]=c(46,100) truth[1:2,6]=c(50,133);truth[1:2,7]=c(100,151);truth[1,8]=133;truth[1,9]=151 test_that('crops3',expect_equal(cpts.full(out),truth)) -truth=c(10.59663, 10.68431, 11.31088, 11.38307, 119.78669, 191.42622) +truth=c(10.59663, 10.68431, 11.31088, 11.38307, 119.78669, 191.42622,529.83174) test_that('crops4',expect_equal(pen.value.full(out),truth,tolerance=1e-6)) # Example multiple datasets where the first row has multiple changes in mean and variance and the @@ -198,7 +198,7 @@ out=cpt.var(x,pen.value=c(log(length(x)),100*log(length(x))),penalty="CROPS",met truth=matrix(NA,ncol=7,nrow=7);truth[1:6,1]=50;truth[1:5,2]=c(77,rep(99,3),150);truth[1:4,3]=c(79,114,140,150) truth[1:3,4]=c(99,133,150);truth[1:2,5]=c(114,150);truth[1,6]=133;truth[1,7]=150 test_that('var5',expect_equivalent(cpts.full(out),truth)) -truth=c(5.298317,5.548538,6.149305,7.083099,26.592259,142.417161,145.146279) +truth=c(5.298317,5.548538,6.149305,7.083099,26.592259,142.417161,145.146279,529.831737) test_that('var6',expect_equivalent(pen.value.full(out),truth)) # Example multiple datasets where the first row has multiple changes in variance and the second row diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index 663b841..61542df 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -11,6 +11,6 @@ plot(obj.cpt.range, diagnostic = TRUE, type = "h") # Tests for plots vdiffr::expect_doppelganger("Diagnostic plot (default)", - plot(obj.cpt.range, diagnostic = TRUE)) + plot(obj.cpt.range, diagnostic = TRUE)) vdiffr::expect_doppelganger("Diagnostic plot (histogram)", - plot(obj.cpt.range, diagnostic = TRUE, type = "h")) + plot(obj.cpt.range, diagnostic = TRUE, type = "h"))