Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anomaly-detection): Handle illegal padding amount #1136

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/seer/anomaly_detection/detectors/mp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ 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) < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: len(mp_dist) <= pad_to_len would be a little bit more readable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it should be equal since that just means no padding is added

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. So we should raise error if pad_to_len is less than or equal to len(mp_len).

raise Exception("Requested length should be greater than 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))
Expand Down
Loading