Skip to content

Commit

Permalink
Keep legacy in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Oct 11, 2022
1 parent 2f60b06 commit 53e2639
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ dtwSat-Ex_x64.Rout
examples_i386
examples_x64
vignettes/twdtw03-speed.Rmd


^data/mod13q1/
^data/mod13q1.db
^CRAN-RELEASE$
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ Imports:
xtable,
Rdpack,
data.table,
foreach,
parallel
foreach
Suggests:
gridExtra,
grid,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ importFrom(stats,sd)
importFrom(stats,window)
importFrom(stats,xtabs)
importFrom(utils,flush.console)
importFrom(utils,globalVariables)
importFrom(utils,packageDescription)
importFrom(xtable,print.xtable)
importFrom(xtable,xtable)
Expand Down
5 changes: 3 additions & 2 deletions R/class-twdtwMatches.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#' @examples
#' ts = twdtwTimeSeries(timeseries=MOD13Q1.ts.list)
#' patterns = twdtwTimeSeries(timeseries=MOD13Q1.patterns.list)
#' matches = twdtwApply(x = ts, y = patterns)
#' matches = twdtwApply(x = ts, y = patterns, keep=TRUE, legacy=TRUE)
#' class(matches)
#' length(matches)
#' matches
Expand Down Expand Up @@ -128,7 +128,8 @@ setGeneric(name = "twdtwMatches",
#' # Creating objects of class twdtwMatches
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat = twdtwApply(ts, patt, weight.fun = logisticWeight(-0.1, 100))
#' mat = twdtwApply(ts, patt, weight.fun = logisticWeight(-0.1, 100),
#' keep=TRUE, legacy=TRUE)
#' mat = twdtwMatches(ts, patterns=patt, alignments=mat)
#' mat
#'
Expand Down
3 changes: 2 additions & 1 deletion R/getInternals.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ setGeneric("getMatches", function(object, timeseries.labels=NULL, patterns.label
#' # Getting patterns from objects of class twdtwMatches
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100), keep=TRUE)
#' mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100),
#' keep=TRUE, legacy = TRUE)
#' getPatterns(mat)
#' getTimeSeries(mat)
#' getAlignments(mat)
Expand Down
2 changes: 1 addition & 1 deletion R/getTimeSeries.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ setGeneric("getPatterns", function(object, ...) standardGeneric("getPatterns"))
#' # Getting time series from objects of class twdtwTimeSeries
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat = twdtwApply(x=ts, y=patt)
#' mat = twdtwApply(x=ts, y=patt, keep=TRUE, legacy=TRUE)
#' getTimeSeries(mat, 2)
#'
#' ## This example creates a twdtwRaster object and extract time series from it.
Expand Down
4 changes: 2 additions & 2 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ setMethod("[", "twdtwMatches", function(x, i, j, drop=TRUE) {
if(missing(i)) i = 1:length(x@alignments)
# if(missing(j)) j = 2:length(x@patterns)
if(any(is.na(i))) stop("NA index not permitted")
if(class(i)=="character") i = match(i, names(x@timeseries@timeseries))
if(is(i, "character")) i = match(i, names(x@timeseries@timeseries))
res = x@alignments[i]
if(missing(j)) j = 1:length(res[[1]])
if(class(j)=="character") j = match(j, names(x@patterns@timeseries))
if(is(j, "character")) j = match(j, names(x@patterns@timeseries))
if(any(is.na(j))) stop("NA index not permitted")
res = lapply(res, function(x) x[j])
res = res[sapply(res, length)>0]
Expand Down
4 changes: 2 additions & 2 deletions R/plotAccuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
plotAccuracy = function(x, perc=TRUE, conf.int=.95, time.labels=NULL,
category.name=NULL, category.type=NULL){

if(class(x)=="twdtwCrossValidation"){
if(is(x, "twdtwCrossValidation")){
gp = .plotCrossValidation(x, conf.int, perc, category.name, category.type)
} else {
if(class(x)=="twdtwAssessment"){
if(is(x, "twdtwAssessment")){
gp = .plotAssessmentAccuracy(x, perc, time.labels, category.name, category.type)
} else {
stop("Class of x is not twdtwAssessment or twdtwCrossValidation")
Expand Down
2 changes: 1 addition & 1 deletion R/plotAlignments.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#' log_fun = logisticWeight(-0.1, 100)
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE, legacy=TRUE)
#'
#' plotAlignments(mat1)
#'
Expand Down
2 changes: 1 addition & 1 deletion R/plotClassification.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#' log_fun = logisticWeight(-0.1, 100)
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE, legacy=TRUE)
#'
#' # Classify interval
#' from = as.Date("2007-09-01")
Expand Down
2 changes: 1 addition & 1 deletion R/plotMatches.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#' log_fun = logisticWeight(-0.1, 100)
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE, legacy=TRUE)
#'
#' plotMatches(mat1)
#'
Expand Down
3 changes: 2 additions & 1 deletion R/subset.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
#' ts
#' # Getting time series from objects of class twdtwTimeSeries
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100))
#' mat = twdtwApply(x=ts, y=patt, weight.fun=logisticWeight(-0.1,100),
#' keep=TRUE, legacy=TRUE)
#' mat = subset(mat, k=4)
#'
#' ## This example creates a twdtwRaster object and extracts time series from it.
Expand Down
6 changes: 3 additions & 3 deletions R/twdtwApply.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ setGeneric(name = "twdtwApply",
#' log_fun = logisticWeight(-0.1, 100)
#' ts = twdtwTimeSeries(MOD13Q1.ts.list)
#' patt = twdtwTimeSeries(MOD13Q1.patterns.list)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun)
#' mat1 = twdtwApply(x=ts, y=patt, weight.fun=log_fun, keep=TRUE, legacy=TRUE)
#' mat1
#'
#' \dontrun{
Expand Down Expand Up @@ -299,10 +299,10 @@ twdtwApply.twdtwRaster.fast = function(x,

# Apply TWDTW analysis
twdtw_results <- foreach(
i = ts,
tsidopar = ts,
.combine = 'rbind'
) %dopar% {
res = twdtwReduceTime(x = i, y = y, breaks = breaks, fill = fill, alpha = alpha, beta = beta, keep = FALSE, ...)
res = twdtwReduceTime(x = tsidopar, y = y, breaks = breaks, fill = fill, alpha = alpha, beta = beta, keep = FALSE, ...)
twdtw_label <- matrix(res$label, ncol = length(breaks)-1, byrow = TRUE)
twdtw_distance <- matrix(res$distance, ncol = length(breaks)-1, byrow = TRUE)
cbind(twdtw_label, twdtw_distance)
Expand Down
6 changes: 4 additions & 2 deletions R/twdtwClassify.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @description This function classifies the intervals of a time series
#' based on the TWDTW results.
#'
#' @inheritParams get
#' @inheritParams twdtwReduceTime
#'
#' @param x An object of class twdtw*. This is the target time series.
#' Usually, it is a set of unclassified time series.
Expand All @@ -39,6 +39,8 @@
#' between one match and the interval of classification. Default is 0.5,
#' \emph{i.e.} an overlap minimum of 50\%.
#'
#' @param patterns.labels a vector with labels of the patterns.
#'
#' @param thresholds A numeric vector the same length as \code{patterns.labels}.
#' The TWDTW dissimilarity thresholds, i.e. the maximum TWDTW cost for consideration
#' in the classification. Default is \code{Inf} for all \code{patterns.labels}.
Expand Down Expand Up @@ -104,7 +106,7 @@ setMethod("twdtwClassify", "twdtwTimeSeries",
function(x, patterns.labels=NULL, from=NULL, to=NULL, by=NULL, breaks=NULL,
overlap=.5, thresholds=Inf, fill="unclassified", ...){
xm = twdtwApply(x = x, from = from, to = to, by = by, breaks = breaks, ...)
if(class(xm) == "twdtwMatches"){
if(is(xm, "twdtwMatches")){
x = xm
if(is.null(patterns.labels)) patterns.labels = labels(x@patterns)
if( overlap < 0 & 1 < overlap )
Expand Down
2 changes: 1 addition & 1 deletion R/twdtw_reduce_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ twdtwReduceTime = function(x,
} else {
stop("Fortran bestmatches lib is not loaded")
}
if(class(res) == "try-error"){
if(is(res, "try-error")){
res = list(
XM = matrix(as.integer(c(as.numeric(tx[x[,1]]), as.numeric(tx[x[,3]]))), ncol = 2),
AM = matrix(as.double(.Machine$double.xmax), nrow = n, ncol = m),
Expand Down
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
#' @importFrom lubridate month month<- day day<- year year<-
#' @importFrom caret createDataPartition
#' @importFrom xtable xtable print.xtable
#' @importFrom utils packageDescription flush.console
#' @importFrom utils packageDescription flush.console globalVariables
#' @importFrom Rdpack reprompt
#' @importFrom data.table rbindlist
#' @useDynLib dtwSat, .registration = TRUE
#'
NULL

if(getRversion() >= "2.15.1") utils::globalVariables("tsidopar")

### Import and export functions from other packages

Expand Down
10 changes: 8 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Test environments

* Local Ubuntu 20.04 (64-bit), R 4.1.1
* Local Ubuntu 22.04.1 LTS x86_64-pc-linux-gnu (64-bit), R 4.2.1 (2022-06-23)
devtools::check(args = '--as-cran')
devtools::submit_cran()

* win-builder
devtools::check_win_release()
devtools::check_win_devel()
Expand All @@ -15,6 +15,12 @@

## REVIEWS

# v0.2.8

* Fixes errors from https://cran.r-project.org/web/checks/check_results_dtwSat.html

* Speed improvements

# v0.2.7

* Fixes error in cost TWDTW weighting function
Expand Down
3 changes: 2 additions & 1 deletion man/get.Rd

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

2 changes: 1 addition & 1 deletion man/getTimeSeries.Rd

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

2 changes: 1 addition & 1 deletion man/plotAlignments.Rd

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

2 changes: 1 addition & 1 deletion man/plotClassification.Rd

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

2 changes: 1 addition & 1 deletion man/plotMatches.Rd

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

3 changes: 2 additions & 1 deletion man/subset.Rd

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

2 changes: 1 addition & 1 deletion man/twdtwApply.Rd

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

17 changes: 17 additions & 0 deletions man/twdtwClassify.Rd

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

5 changes: 3 additions & 2 deletions man/twdtwMatches-class.Rd

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

0 comments on commit 53e2639

Please sign in to comment.