Skip to content

Commit 05a1ebb

Browse files
author
Ashley Scillitoe
authored
Fixes for numpy >= 1.24 (#826)
Removes numpy typing aliases, e.g. np.int replaced with int
1 parent 3ddb2ca commit 05a1ebb

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ repos:
44
hooks:
55
- id: flake8
66
- repo: https://github.com/pre-commit/mirrors-mypy
7-
rev: v1.0.1
7+
rev: v1.4.1
88
hooks:
99
- id: mypy
1010
additional_dependencies: [
11-
types-requests~=2.28,
11+
types-requests~=2.31,
1212
types-toml~=0.10
1313
]

alibi_detect/cd/base_online.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ def _check_x(self, x: Any, x_ref: bool = False) -> np.ndarray:
342342
# Check the type of x
343343
if isinstance(x, np.ndarray):
344344
pass
345-
# TODO: np.int, np.float checks deprecated in numpy 1.20
346-
elif isinstance(x, (int, float, np.int, np.float)): # type: ignore[attr-defined]
345+
elif isinstance(x, (int, float)):
347346
x = np.array([x])
348347
else:
349348
raise TypeError("Detectors expect data to be 2D np.ndarray's. If data is passed as another type, a "

alibi_detect/cd/sklearn/classifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _score_rf(self, x: Union[np.ndarray, list]) \
298298
probs_oob = self.model.oob_decision_function_[idx_oob]
299299
y_oob = y[idx_oob]
300300
if isinstance(x, np.ndarray):
301-
x_oob = x[idx_oob]
301+
x_oob: Union[list, np.ndarray] = x[idx_oob]
302302
elif isinstance(x, list):
303303
x_oob = [x[_] for _ in idx_oob]
304304
else:

alibi_detect/utils/perturbation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import random
22
from io import BytesIO
3-
from typing import List, Tuple
3+
from typing import List, Tuple, Union
44

55
import cv2
66
import numpy as np
@@ -80,7 +80,7 @@ def apply_mask(X: np.ndarray,
8080
for _ in range(x_start.shape[0]):
8181

8282
if mask_type == 'zero':
83-
update_val = 0
83+
update_val: Union[float, np.ndarray] = 0.0
8484
else:
8585
update_val = noise[_]
8686

0 commit comments

Comments
 (0)