Skip to content
Merged
Changes from all commits
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
11 changes: 10 additions & 1 deletion giskard/push/perturbation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Optional

import hashlib
import numbers

import numpy as np
import pandas as pd
Expand All @@ -35,6 +36,14 @@

from ..push import PerturbationPush

try:
from pandas.api.types import is_any_real_numeric_dtype
except ImportError:

def is_any_real_numeric_dtype(array: np.array) -> bool:
return issubclass(array.dtype.type, numbers.Real)


text_transformation_list = [
TextLowercase,
TextUppercase,
Expand Down Expand Up @@ -121,7 +130,7 @@ def _apply_perturbation(
ds_slice_copy = ds_slice.copy()

# Apply the transformation
if col_type == SupportedPerturbationType.NUMERIC:
if col_type == SupportedPerturbationType.NUMERIC and is_any_real_numeric_dtype(ds_slice.df[feature]):
passed = _numeric(
ds,
ds_slice,
Expand Down