Skip to content

Commit

Permalink
chore: add data shape validation
Browse files Browse the repository at this point in the history
Signed-off-by: Avik Basu <ab93@users.noreply.github.com>
  • Loading branch information
ab93 committed Jul 26, 2023
1 parent 2da4ea0 commit 929d93b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion numalogic/models/threshold/_mahalanobis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

_INLIER: Final[int] = 0
_OUTLIER: Final[int] = 1
_INPUT_DIMS = Final[int] = 2


class MahalanobisThreshold(BaseThresholdModel):
Expand Down Expand Up @@ -87,7 +88,7 @@ def _chebyshev_k(p: float) -> float:
@staticmethod
def _validate_input(x: npt.NDArray[float]) -> None:
"""Validate the input matrix shape."""
if x.ndim != 2:
if x.ndim != _INPUT_DIMS:
raise InvalidDataShapeError(f"Input matrix should have 2 dims, given shape: {x.shape}.")

def fit(self, x: npt.NDArray[float]) -> Self:
Expand Down

0 comments on commit 929d93b

Please sign in to comment.