Skip to content

Commit c69b39d

Browse files
committed
better comment
1 parent 7cbaf46 commit c69b39d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/ml3_drift/sklearn/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,17 @@ def _safe_nan_clean(self, X):
231231
else:
232232
return X[~np.any(np.isnan(X))]
233233
elif np.issubdtype(X.dtype, np.object_):
234+
# Since the dtype is object we cannot apply the function np.isnan
235+
# Therefore, we need to iterate over each row
236+
# According to the number of columns we can have an array or a scalar
237+
# if it is an array then we cast it to a list and check if it contains None
238+
# if it is a scalar then we use np.isnan if it is a float or not None otherwise
234239
return X[
235240
np.array(
236241
[
237242
[
238243
not (
239-
(isinstance(x, list) and None in x)
240-
or (
241-
isinstance(x, np.ndarray) and None in x.tolist()
242-
)
244+
(isinstance(x, np.ndarray) and None in x.tolist())
243245
or (isinstance(x, float) and np.isnan(x))
244246
or (x is None)
245247
)

0 commit comments

Comments
 (0)