Skip to content

Commit fb5a64a

Browse files
committed
Merge pull request twitter#55 from terrytangyuan/issue39
Consistent output when no anomalies detected - fixed Issue39
2 parents 58dea61 + b9399b2 commit fb5a64a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

R/ts_anom_detection.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ AnomalyDetectionTs <- function(x, max_anoms = 0.10, direction = 'pos',
279279
# If there are no anoms, then let's exit
280280
if(anom_pct == 0){
281281
if(verbose) message("No anomalies detected.")
282-
return (list("anoms"=NULL, "plot"=NULL))
282+
return (list("anoms"=data.frame(), "plot"=plot.new()))
283283
}
284284

285285
if(plot){
@@ -341,6 +341,6 @@ AnomalyDetectionTs <- function(x, max_anoms = 0.10, direction = 'pos',
341341
if(plot){
342342
return (list(anoms = anoms, plot = xgraph))
343343
} else {
344-
return (list(anoms = anoms, plot = NULL))
344+
return (list(anoms = anoms, plot = plot.new()))
345345
}
346346
}

R/vec_anom_detection.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ AnomalyDetectionVec = function(x, max_anoms=0.10, direction='pos',
224224
# If there are no anoms, then let's exit
225225
if(anom_pct == 0){
226226
if(verbose) message("No anomalies detected.")
227-
return (list("anoms"=NULL, "plot"=NULL))
227+
return (list("anoms"=data.frame(), "plot"=plot.new()))
228228
}
229229

230230
if(plot){
@@ -287,6 +287,6 @@ AnomalyDetectionVec = function(x, max_anoms=0.10, direction='pos',
287287
if(plot){
288288
return (list(anoms = anoms, plot = xgraph))
289289
} else {
290-
return (list(anoms = anoms, plot = NULL))
290+
return (list(anoms = anoms, plot = plot.new()))
291291
}
292292
}

0 commit comments

Comments
 (0)