Skip to content

Commit 421295e

Browse files
committed
ruff formatting
1 parent 43f3a2f commit 421295e

37 files changed

+66
-107
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ jobs:
630630
token: ${{ secrets.CODECOV_TOKEN }}
631631

632632
format_clang:
633-
needs: [bdist] # bdist is not needed but slow this step down
634633
runs-on: ubuntu-latest
635634
permissions:
636635
checks: write
@@ -663,8 +662,7 @@ jobs:
663662
conclusion: 'neutral'
664663
})
665664
666-
format_black:
667-
needs: [bdist] # bdist is not needed but slow this step down
665+
format_ruff:
668666
runs-on: ubuntu-latest
669667
permissions:
670668
checks: write
@@ -673,13 +671,13 @@ jobs:
673671
uses: actions/checkout@v4
674672
with:
675673
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
676-
- name: Check python matches black format
674+
- name: Check python matches ruff format
677675
id: check_python
678676
continue-on-error: true
679677
run: |
680678
cd python
681-
python -m pip install --upgrade black
682-
black --check .
679+
python -m pip install --upgrade ruff
680+
ruff format --check
683681
- name: Mark step with a warning
684682
if: ${{ steps.check_python.outcome == 'failure' }}
685683
uses: actions/github-script@v6
@@ -688,7 +686,7 @@ jobs:
688686
github.rest.checks.create({
689687
owner: context.repo.owner,
690688
repo: context.repo.repo,
691-
name: 'Failed black formatting check',
689+
name: 'Failed ruff formatting check',
692690
head_sha: context.sha,
693691
status: 'completed',
694692
conclusion: 'neutral'

python/interpret-core/interpret/api/templates.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ def visualize(self, key=None, title=None):
126126
perf=perf[key],
127127
)
128128
# pragma: no cover
129-
raise RuntimeError(
130-
f"Visual provider {provider} not supported"
131-
)
129+
raise RuntimeError(f"Visual provider {provider} not supported")
132130
is_multiclass = is_multiclass_local_data_dict(data_dict)
133131
if is_multiclass:
134132
# Sort by predicted class' abs feature values

python/interpret-core/interpret/blackbox/_sensitivity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(
5959
feature_names=None,
6060
feature_types=None,
6161
sampler=None,
62-
**kwargs
62+
**kwargs,
6363
):
6464
"""Initializes class.
6565

python/interpret-core/interpret/data/_response.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ def explain_data(self, X, y, name=None):
9090
}
9191

9292
# Sample down
93-
n_samples = (
94-
min(len(y), self.max_scatter_samples)
95-
)
93+
n_samples = min(len(y), self.max_scatter_samples)
9694
idx = np.random.choice(np.arange(len(y)), n_samples, replace=False)
9795
X_sample = X[idx, :]
9896
y_sample = y[idx]
@@ -277,9 +275,7 @@ def visualize(self, key=None):
277275
hovermode="closest",
278276
xaxis2=dict(domain=[do_hi, 1], showgrid=False, zeroline=False),
279277
yaxis2=dict(domain=[do_hi, 1], showgrid=False, zeroline=False),
280-
title=(
281-
f"Pearson Correlation: {corr:.3f}" if corr is not None else ""
282-
),
278+
title=(f"Pearson Correlation: {corr:.3f}" if corr is not None else ""),
283279
)
284280
fig = go.Figure(data=data, layout=layout)
285281
return fig

python/interpret-core/interpret/ext/extension.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ def _is_valid_explainer(proposed_explainer, expected_explainer_type):
1919
available_explanations = proposed_explainer.available_explanations
2020

2121
if explainer_type != expected_explainer_type:
22-
_log.warning(
23-
f"Proposed explainer is not a {expected_explainer_type}."
24-
)
22+
_log.warning(f"Proposed explainer is not a {expected_explainer_type}.")
2523
return False
2624

2725
for available_explanation in available_explanations:

python/interpret-core/interpret/glassbox/_decisiontree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def __init__(self, feature_names=None, feature_types=None, max_depth=3, **kwargs
560560
feature_names=feature_names,
561561
feature_types=feature_types,
562562
max_depth=max_depth,
563-
**kwargs
563+
**kwargs,
564564
)
565565

566566
def _model(self):
@@ -603,7 +603,7 @@ def __init__(self, feature_names=None, feature_types=None, max_depth=3, **kwargs
603603
feature_names=feature_names,
604604
feature_types=feature_types,
605605
max_depth=max_depth,
606-
**kwargs
606+
**kwargs,
607607
)
608608

609609
def _model(self):

python/interpret-core/interpret/glassbox/_ebm/_tensor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def trim_tensor(tensor, trim_low=None, trim_high=None):
1919
]
2020
elif trim_high is None:
2121
dim_slices = [
22-
slice(int(is_low), None)
23-
for dim_len, is_low in zip(tensor.shape, trim_low)
22+
slice(int(is_low), None) for dim_len, is_low in zip(tensor.shape, trim_low)
2423
]
2524
else:
2625
dim_slices = [

python/interpret-core/interpret/provider/_visualize.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ def render_html(html_string):
104104
display_html(final_html, raw=True)
105105

106106
if visual is None: # pragma: no cover
107-
msg = (
108-
f"No visualization for explanation [{explanation_name}] with selector_key [{selector_key}]"
109-
)
107+
msg = f"No visualization for explanation [{explanation_name}] with selector_key [{selector_key}]"
110108
_log.error(msg)
111109
if file_name is None:
112110
render_html(msg)

python/interpret-core/interpret/utils/_SPOTgreedy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2023 The InterpretML Contributors
22
# Distributed under the MIT software license
33

4-
""" SPOT: A framework for selection of prototypes using optimal transport
4+
"""SPOT: A framework for selection of prototypes using optimal transport
55
66
This file implements the SPOTgreedy algorithm from [1].
77

python/interpret-core/interpret/utils/_measure_interactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2023 The InterpretML Contributors
22
# Distributed under the MIT software license
33

4-
""" FAST - Interaction Detection
4+
"""FAST - Interaction Detection
55
66
This module exposes a method called FAST [1] to measure and rank the strengths
77
of the interaction of all pairs of features in a dataset.

0 commit comments

Comments
 (0)