seasonal-esd-anomaly-detection
seasonal-esd-anomaly-detection copied to clipboard
anomalous_indices not sliced correctly if only one value> crit_value
for curr in range(max_anomalies):
test_idx, test_val = calculate_test_statistic(ts, hybrid=hybrid)
critical_val = calculate_critical_value(len(ts) - curr, alpha)
if test_val > critical_val:
num_outliers = curr
test_statistics.append(test_idx)
ts[test_idx] = np.ma.masked # Mask this index so that we don't consider it in subsequent ESD tests.
**anomalous_indices = test_statistics[:num_outliers + 1] if num_outliers > 0 else []**
setting num_outliers to curr failed for me because my only outlier was in the first iteration so it was set to 0 which didn't meet the if statement
I think this should work anomalous_indices = test_statistics[:num_outliers + 1] if len(test_statistics)>0 else []