From 3396a07a0e16f1cbaa1fa27847dfde7c30d89527 Mon Sep 17 00:00:00 2001 From: aho Date: Thu, 6 Feb 2020 13:02:12 +0100 Subject: [PATCH] Fix for CRAN --- DESCRIPTION | 4 ++-- NAMESPACE | 8 ++++++++ NEWS.md | 2 +- R/InsertDim.R | 2 +- R/RMS.R | 2 +- R/RMSSS.R | 1 + R/Regression.R | 1 + R/ToyModel.R | 11 ++++++----- R/Utils.R | 1 + inst/config/BSC.conf | 4 ++-- inst/config/template.conf | 4 ++-- man/ToyModel.Rd | 11 ++++++----- man/s2dv-package.Rd | 4 ++-- tests/testthat/test-Clim.R | 2 +- tests/testthat/test-Corr.R | 6 +++--- tests/testthat/test-Eno.R | 2 +- tests/testthat/test-InsertDim.R | 2 +- tests/testthat/test-MeanDims.R | 11 +++++------ tests/testthat/test-RMS.R | 6 +++--- tests/testthat/test-RMSSS.R | 2 +- tests/testthat/test-Regression.R | 10 +++++----- tests/testthat/test-Reorder.R | 5 ++--- tests/testthat/test-Season.R | 18 +++++++++--------- tests/testthat/test-Trend.R | 10 +++++----- 24 files changed, 70 insertions(+), 59 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9d99347..f6d30e6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: s2dv -Title: Set of Common Tools for Seasonal to Decadal Verification +Title: A Set of Common Tools for Seasonal to Decadal Verification Version: 0.0.1 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), @@ -10,7 +10,7 @@ Description: The advanced version of package 's2dverification'. It is it can also be used in other kinds of forecasts or general climate analysis. This package is specially designed for the comparison between the experimental and observational datasets. The functionality of the included functions covers - from data retrieval, data post-processing, skill scores against obeservation, + from data retrieval, data post-processing, skill scores against observation, to visualization. Compared to 's2dverification', 's2dv' adopts the regime of package 'multiApply'. Therefore, it can use multi-core for computation and work with multi-dimensional arrays with a higher level of flexibility. diff --git a/NAMESPACE b/NAMESPACE index 8be5ed8..627bf51 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -49,15 +49,21 @@ import(parallel) importFrom(ClimProjDiags,Subset) importFrom(abind,abind) importFrom(abind,adrop) +importFrom(grDevices,bmp) importFrom(grDevices,col2rgb) importFrom(grDevices,colorRampPalette) importFrom(grDevices,dev.cur) importFrom(grDevices,dev.new) importFrom(grDevices,dev.off) importFrom(grDevices,gray) +importFrom(grDevices,jpeg) +importFrom(grDevices,pdf) +importFrom(grDevices,png) importFrom(grDevices,postscript) importFrom(grDevices,rainbow) importFrom(grDevices,rgb) +importFrom(grDevices,svg) +importFrom(grDevices,tiff) importFrom(plyr,take) importFrom(stats,acf) importFrom(stats,confint) @@ -67,7 +73,9 @@ importFrom(stats,median) importFrom(stats,na.fail) importFrom(stats,na.omit) importFrom(stats,na.pass) +importFrom(stats,pf) importFrom(stats,pt) +importFrom(stats,qchisq) importFrom(stats,qnorm) importFrom(stats,rnorm) importFrom(stats,ts) diff --git a/NEWS.md b/NEWS.md index c216382..8290870 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# s2dv 0.0.1 (Release date: 2020-02-) +# s2dv 0.0.1 (Release date: 2020-02-07) - The package is the advanced version of package 's2dverification', adopting the regime of package 'multiApply' for all the analytic functions. Most of the other functions for plotting and data retrieval in 's2dverification' are also preserved in this package. - Because of the adoption of 'multiApply' regime, the functions work well with package 'startR'. - All the packages mentioned above are developed by BSC-CNS. diff --git a/R/InsertDim.R b/R/InsertDim.R index 1ec5b8f..cf78665 100644 --- a/R/InsertDim.R +++ b/R/InsertDim.R @@ -106,7 +106,7 @@ InsertDim <- function(data, posdim, lendim, name = NULL, ncores = NULL) { return(res) } -.InsertDim <- function(x, dat) { +.InsertDim <- function(x, data) { x <- data return(x) } diff --git a/R/RMS.R b/R/RMS.R index cc522f5..e9038ed 100644 --- a/R/RMS.R +++ b/R/RMS.R @@ -60,6 +60,7 @@ #'@rdname RMS #'@import multiApply #'@importFrom ClimProjDiags Subset +#'@importFrom stats qchisq #'@export RMS <- function(exp, obs, time_dim = 'sdate', memb_dim = 'member', comp_dim = NULL, limits = NULL, @@ -179,7 +180,6 @@ RMS <- function(exp, obs, time_dim = 'sdate', memb_dim = 'member', return(res) } - .RMS <- function(exp, obs, time_dim = 'sdate', memb_dim = 'member', conf = TRUE, conf.lev = 0.95) { diff --git a/R/RMSSS.R b/R/RMSSS.R index fa5cca9..4f115d3 100644 --- a/R/RMSSS.R +++ b/R/RMSSS.R @@ -49,6 +49,7 @@ #' #'@rdname RMSSS #'@import multiApply +#'@importFrom stats pf #'@export RMSSS <- function(exp, obs, time_dim = 'sdate', memb_dim = 'member', pval = TRUE, ncores = NULL) { diff --git a/R/Regression.R b/R/Regression.R index 98ef4d2..1e0c79b 100644 --- a/R/Regression.R +++ b/R/Regression.R @@ -30,6 +30,7 @@ #' computation. Default value is NULL. #' #'@import multiApply +#'@importFrom stats pf #'@return #'A list containing: #'\item{$regression}{ diff --git a/R/ToyModel.R b/R/ToyModel.R index 0919a2e..2a0a47f 100644 --- a/R/ToyModel.R +++ b/R/ToyModel.R @@ -93,11 +93,12 @@ #' #'toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, nmemb = nm, #' obsini = sampleData$obs, nstartd = 5, nleadt = 60) -#' \donttest{ -#'PlotAno(toyforecast$mod, toyforecast$obs, startDates, -#' toptitle = c("Synthetic decadal temperature prediction"), -#' fileout = "ex_toymodel.eps") -#' } +#'## Add PlotAno() back when this function is included!! +#'# \donttest{ +#'#PlotAno(toyforecast$mod, toyforecast$obs, startDates, +#'# toptitle = c("Synthetic decadal temperature prediction"), +#'# fileout = "ex_toymodel.eps") +#'# } #' #'@importFrom stats rnorm #'@export diff --git a/R/Utils.R b/R/Utils.R index bb34426..86b2644 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -1,5 +1,6 @@ #'@importFrom abind abind #'@importFrom plyr take +#'@importFrom grDevices png jpeg pdf svg bmp tiff #'@import ncdf4 ## Function to tell if a regexpr() match is a complete match to a specified name diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index aca91db..1ee7184 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -1,6 +1,6 @@ -# s2dverification configuration file +# s2dv configuration file # -# Check ?ConfigFileOpen after loading s2dverification for detailed +# Check ?ConfigFileOpen after loading s2dv for detailed # documentation on this configuration file. ############# diff --git a/inst/config/template.conf b/inst/config/template.conf index b6f727e..e155c8f 100644 --- a/inst/config/template.conf +++ b/inst/config/template.conf @@ -1,6 +1,6 @@ -# s2dverification configuration file +# s2dv configuration file # -# Check ?LoadConfigurationFile after loading s2dverification for detailed +# Check ?LoadConfigurationFile after loading s2dv for detailed # documentation on this configuration file. ################# diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index 64feac8..379ed3b 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -112,11 +112,12 @@ nm <- 10 toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, nmemb = nm, obsini = sampleData$obs, nstartd = 5, nleadt = 60) - \donttest{ -PlotAno(toyforecast$mod, toyforecast$obs, startDates, - toptitle = c("Synthetic decadal temperature prediction"), - fileout = "ex_toymodel.eps") - } +## Add PlotAno() back when this function is included!! +# \donttest{ +#PlotAno(toyforecast$mod, toyforecast$obs, startDates, +# toptitle = c("Synthetic decadal temperature prediction"), +# fileout = "ex_toymodel.eps") +# } } diff --git a/man/s2dv-package.Rd b/man/s2dv-package.Rd index 7cd5479..fc3eb94 100644 --- a/man/s2dv-package.Rd +++ b/man/s2dv-package.Rd @@ -4,14 +4,14 @@ \name{s2dv-package} \alias{s2dv} \alias{s2dv-package} -\title{Set of Common Tools for Seasonal to Decadal Verification} +\title{A Set of Common Tools for Seasonal to Decadal Verification} \description{ The advanced version of package 's2dverification'. It is intended for 'seasonal to decadal' (s2d) climate forecast verification, but it can also be used in other kinds of forecasts or general climate analysis. This package is specially designed for the comparison between the experimental and observational datasets. The functionality of the included functions covers -from data retrieval, data post-processing, skill scores against obeservation, +from data retrieval, data post-processing, skill scores against observation, to visualization. Compared to 's2dverification', 's2dv' adopts the regime of package 'multiApply'. Therefore, it can use multi-core for computation and work with multi-dimensional arrays with a higher level of flexibility. diff --git a/tests/testthat/test-Clim.R b/tests/testthat/test-Clim.R index d9617a9..835f59f 100644 --- a/tests/testthat/test-Clim.R +++ b/tests/testthat/test-Clim.R @@ -1,4 +1,4 @@ -context("s2dverification::Clim tests") +context("s2dv::Clim tests") ############################################## # dat1 diff --git a/tests/testthat/test-Corr.R b/tests/testthat/test-Corr.R index 490f5e7..d1694f9 100644 --- a/tests/testthat/test-Corr.R +++ b/tests/testthat/test-Corr.R @@ -1,4 +1,4 @@ -context("s2dverification::Corr tests") +context("s2dv::Corr tests") ############################################## # dat1 @@ -133,8 +133,8 @@ test_that("2. Output checks: dat1", { 2 ) expect_equal( - summary(Corr(exp1, obs1, conf.lev = 0.99)$conf.upper)[1], - c(Min. = 0.2748), + min(Corr(exp1, obs1, conf.lev = 0.99)$conf.upper, na.rm = TRUE), + 0.2747904, tolerance = 0.0001 ) expect_equal( diff --git a/tests/testthat/test-Eno.R b/tests/testthat/test-Eno.R index 1b85092..08fda85 100644 --- a/tests/testthat/test-Eno.R +++ b/tests/testthat/test-Eno.R @@ -1,4 +1,4 @@ -context("s2dverification::Eno tests") +context("s2dv::Eno tests") ############################################## set.seed(1) diff --git a/tests/testthat/test-InsertDim.R b/tests/testthat/test-InsertDim.R index eb627fb..c4d3226 100644 --- a/tests/testthat/test-InsertDim.R +++ b/tests/testthat/test-InsertDim.R @@ -1,4 +1,4 @@ -context("s2dverification::InsertDim tests") +context("s2dv::InsertDim tests") ############################################## dat1 <- array(c(1:26), dim = c(dat = 1, sdate = 13, ftime = 2)) diff --git a/tests/testthat/test-MeanDims.R b/tests/testthat/test-MeanDims.R index 7e0f7fb..9c7c566 100644 --- a/tests/testthat/test-MeanDims.R +++ b/tests/testthat/test-MeanDims.R @@ -86,14 +86,13 @@ test_that("2. Output checks: dat1", { test_that("3. Output checks: dat2", { expect_equal( - summary(MeanDims(dat2, dims = c(1,3), na.rm = TRUE))[4], - c(Mean = 10), - tolerance = 0.01 + mean(MeanDims(dat2, dims = c(1,3), na.rm = TRUE), na.rm = TRUE), + 10 ) expect_equal( - summary(MeanDims(dat2, dims = c(1,3), na.rm = FALSE))[4], - c(Mean = 11.17), - tolerance = 0.01 + mean(MeanDims(dat2, dims = c(1,3), na.rm = FALSE), na.rm = TRUE), + 11.16667, + tolerance = 0.0001 ) expect_equal( length(which(is.na(MeanDims(dat2, dims = c(1,3), na.rm = FALSE)))), diff --git a/tests/testthat/test-RMS.R b/tests/testthat/test-RMS.R index a0aaff6..9394d5a 100644 --- a/tests/testthat/test-RMS.R +++ b/tests/testthat/test-RMS.R @@ -1,4 +1,4 @@ -context("s2dverification::RMS tests") +context("s2dv::RMS tests") ############################################## # dat1 @@ -133,8 +133,8 @@ test_that("2. Output checks: dat1", { 21 ) expect_equal( - summary(RMS(exp1, obs1, conf.lev = 0.99)$conf.upper)[1], - c(Min. = 1.406), + min(RMS(exp1, obs1, conf.lev = 0.99)$conf.upper, na.rm = TRUE), + 1.406368, tolerance = 0.0001 ) expect_equal( diff --git a/tests/testthat/test-RMSSS.R b/tests/testthat/test-RMSSS.R index a73f90e..9242d6d 100644 --- a/tests/testthat/test-RMSSS.R +++ b/tests/testthat/test-RMSSS.R @@ -1,4 +1,4 @@ -context("s2dverification::RMSSS tests") +context("s2dv::RMSSS tests") ############################################## # case 0 diff --git a/tests/testthat/test-Regression.R b/tests/testthat/test-Regression.R index c966fe9..fd53142 100644 --- a/tests/testthat/test-Regression.R +++ b/tests/testthat/test-Regression.R @@ -1,4 +1,4 @@ -context("s2dverification::Regression tests") +context("s2dv::Regression tests") ############################################## # dat1 @@ -136,13 +136,13 @@ test_that("2. Output checks: dat1", { tolerance = 0.001 ) expect_equal( - summary(Regression(datay1, datax1)$p.val)[1], - c(Min. = 0.005335), + min(Regression(datay1, datax1)$p.val, na.rm = TRUE), + 0.005335, tolerance = 0.0001 ) expect_equal( - summary(Regression(datay1, datax1, formula = y~poly(x, 2, raw = T))$p.val)[3], - c(Median = 0.22560), + mean(Regression(datay1, datax1, formula = y~poly(x, 2, raw = T))$p.val, na.rm = TRUE), + 0.3407307, tolerance = 0.0001 ) }) diff --git a/tests/testthat/test-Reorder.R b/tests/testthat/test-Reorder.R index 6cc799b..0e8e5b5 100644 --- a/tests/testthat/test-Reorder.R +++ b/tests/testthat/test-Reorder.R @@ -71,9 +71,8 @@ test_that("2. Output checks: dat1", { c(sdate = 3, dat = 1, lon = 5, ftime = 2) ) expect_equal( - summary(Reorder(dat1, c(2, 1, 4, 3)))[3], - c(Median = 15.50), - tolerance = 0.01 + max(Reorder(dat1, c(2, 1, 4, 3)), na.rm = TRUE), + 30 ) }) diff --git a/tests/testthat/test-Season.R b/tests/testthat/test-Season.R index b01b242..ab9996a 100644 --- a/tests/testthat/test-Season.R +++ b/tests/testthat/test-Season.R @@ -1,4 +1,4 @@ -context("s2dverification::Season tests") +context("s2dv::Season tests") ############################################## # dat1 @@ -81,13 +81,13 @@ test_that("2. Output checks: dat1", { c(sdate = 3, member = 2, ftime = 2, lon = 3) ) expect_equal( - summary(Season(dat1, monini = 10, moninf = 12, monsup = 2))[3], - c(Median = 0.007925), + median(Season(dat1, monini = 10, moninf = 12, monsup = 2)), + 0.007925, tolerance = 0.0001 ) expect_equal( - summary(Season(dat1, monini = 10, moninf = 2, monsup = 5, method = sum))[3], - c(Median = 0.2732), + median(Season(dat1, monini = 10, moninf = 2, monsup = 5, method = sum)), + 0.2732015, tolerance = 0.0001 ) @@ -97,13 +97,13 @@ test_that("2. Output checks: dat1", { test_that("3. Output checks: dat2", { expect_equal( - summary(Season(dat2, monini = 10, moninf = 12, monsup = 2))[3], - c(Median = -0.01987), + median(Season(dat2, monini = 10, moninf = 12, monsup = 2)), + -0.01986671, tolerance = 0.0001 ) expect_equal( - summary(Season(dat2, monini = 10, moninf = 12, monsup = 2, na.rm = F))[3], - c(Median = 0.06207), + median(Season(dat2, monini = 10, moninf = 12, monsup = 2, na.rm = F), na.rm = TRUE), + 0.06207006, tolerance = 0.0001 ) res <- Season(dat2, monini = 10, moninf = 12, monsup = 2, na.rm = F) diff --git a/tests/testthat/test-Trend.R b/tests/testthat/test-Trend.R index 8843b9e..ac9f14a 100644 --- a/tests/testthat/test-Trend.R +++ b/tests/testthat/test-Trend.R @@ -1,4 +1,4 @@ -context("s2dverification::Trend tests") +context("s2dv::Trend tests") ############################################## # dat1 @@ -87,8 +87,8 @@ test_that("2. Output checks: dat1", { tolerance = 0.0001 ) expect_equal( - summary(Trend(dat1)$detrended)[3], - c(Median = 0.1154), + median(Trend(dat1)$detrended, na.rm = TRUE), + 0.1153846, tolerance = 0.001 ) @@ -130,8 +130,8 @@ test_that("3. Output checks: dat2", { test_that("4. Output checks: dat3", { expect_equal( - summary(Trend(dat3)$trend)[3], - c(Median = 1.3680), + median(Trend(dat3)$trend, na.rm = TRUE), + 1.368071, tolerance = 0.0001 ) expect_equal( -- GitLab