From bdf389fd99f03984a133d9ec88f50113624827c2 Mon Sep 17 00:00:00 2001 From: Aayush Seth Date: Mon, 9 Sep 2024 16:15:04 -0700 Subject: [PATCH] fix(anomaly-detection): Handle illegal padding amount (#1136) - Util raises exception if requested length for padding is less than current mp_dist array Note: is there a more graceful way to handle this? --- src/seer/anomaly_detection/detectors/mp_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/seer/anomaly_detection/detectors/mp_utils.py b/src/seer/anomaly_detection/detectors/mp_utils.py index bf84f34d9..5dfe2571d 100644 --- a/src/seer/anomaly_detection/detectors/mp_utils.py +++ b/src/seer/anomaly_detection/detectors/mp_utils.py @@ -42,6 +42,10 @@ def get_mp_dist_from_mp( mp_dist = normalizer.normalize(mp_dist) if pad_to_len is not None: + if pad_to_len < len(mp_dist): + raise Exception( + "Requested length should be greater than or equal to current mp_dist" + ) nan_value_count = np.empty(pad_to_len - len(mp_dist)) nan_value_count.fill(np.nan) mp_dist_updated = np.concatenate((nan_value_count, mp_dist))