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 E721 linting errors #958

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions alibi/explainers/tests/test_shap_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,10 @@ def test__summarise_background_kernel(caplog,
msg = "Received option to summarise the data but the background_data object was an " \
"instance of shap_utils.Data"
assert_message_in_logs(msg, caplog.records)
assert type(background_data) == type(summary_data)
assert type(background_data) == type(summary_data) # noqa: E721
else:
if use_groups or categorical_names:
assert type(background_data) == type(summary_data)
assert type(background_data) == type(summary_data) # noqa: E721
if data_type == 'series':
assert summary_data.shape == background_data.shape
else:
Expand Down Expand Up @@ -1181,14 +1181,14 @@ def test__summarise_background_tree(mock_tree_shap_explainer, data_dimension, da
assert explainer.summarise_background
if n_background_samples > n_instances:
if categorical_names:
assert type(background_data) == type(summary_data)
assert type(background_data) == type(summary_data) # noqa: E721
else:
assert isinstance(summary_data, shap_utils.Data)
assert summary_data.data.shape == background_data.shape
else:
if categorical_names:
assert summary_data.shape[0] == n_background_samples
assert type(background_data) == type(summary_data)
assert type(background_data) == type(summary_data) # noqa: E721
else:
assert summary_data.data.shape[0] == n_background_samples
assert isinstance(summary_data, shap_utils.Data)
Expand Down
2 changes: 1 addition & 1 deletion alibi/utils/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def batch_compute_kernel_matrix(x: Union[list, np.ndarray],
-------
Kernel matrix in the form of a `numpy` array.
"""
if type(x) != type(y):
if type(x) != type(y): # noqa: E721
raise ValueError("x and y should be of the same type")

n_x, n_y = len(x), len(y)
Expand Down
2 changes: 1 addition & 1 deletion alibi/utils/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def ord_to_num(data: np.ndarray, dist: dict) -> np.ndarray:
for k, v in dist.items():
cat_col = X[:, k].copy()
cat_col = np.array([v[int(cat_col[i])] for i in range(rng)])
if type(X) == np.matrix:
if isinstance(X, np.matrix):
X[:, k] = cat_col.reshape(-1, 1)
else:
X[:, k] = cat_col
Expand Down