Skip to content

Commit 855454b

Browse files
committed
Merge pull request twitter#50 from terrytangyuan/master
added more checks for input parameter max_anoms.
2 parents fb5a64a + 9430153 commit 855454b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

R/ts_anom_detection.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ AnomalyDetectionTs <- function(x, max_anoms = 0.10, direction = 'pos',
8585
# Sanity check all input parameters
8686
if(max_anoms > .49){
8787
stop(paste("max_anoms must be less than 50% of the data points (max_anoms =", round(max_anoms*length(x[[2]]), 0), " data_points =", length(x[[2]]),")."))
88+
} else if(max_anoms < 0){
89+
stop("max_anoms must be positive.")
90+
} else if(max_anoms == 0){
91+
warning("0 max_anoms results in max_outliers being 0.")
8892
}
8993
if(!direction %in% c('pos', 'neg', 'both')){
9094
stop("direction options are: pos | neg | both.")

0 commit comments

Comments
 (0)