Skip to content

Commit 179df4a

Browse files
committed
Reformat code
1 parent a8142b5 commit 179df4a

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
# Ruff version.
13+
rev: 'v0.5.5'
14+
hooks:
15+
- id: ruff
16+
args: [--fix, --exit-non-zero-on-fix]
17+
- id: ruff-format

.ruff.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Same as Black.
2+
line-length = 88
3+
indent-width = 4
4+
5+
# Assume Python 3.11
6+
target-version = "py311"
7+
8+
[format]
9+
# Like Black, use double quotes for strings.
10+
quote-style = "double"
11+
12+
# Like Black, indent with spaces, rather than tabs.
13+
indent-style = "space"
14+
15+
# Like Black, respect magic trailing commas.
16+
skip-magic-trailing-comma = false
17+
18+
# Like Black, automatically detect the appropriate line ending.
19+
line-ending = "auto"

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2323
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2424
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2525
OTHER DEALINGS IN THE SOFTWARE.
26-

compile_db.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import argparse
2-
import ast
32
import hyperscan
43
import json
54
import pickle
@@ -22,7 +21,7 @@
2221
flags=(hyperscan.HS_FLAG_SINGLEMATCH | hyperscan.HS_FLAG_UTF8,),
2322
)
2423
regexes.add(line)
25-
except hyperscan.error as e:
24+
except hyperscan.error:
2625
pass
2726

2827
# Build input for the final Hyperscan database

explain.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import argparse
22
import io
3-
import json
43
import random
54

65
import matplotlib.pyplot as plt
@@ -42,9 +41,9 @@ def update_sample(samples, N, sample):
4241
)
4342

4443
# See https://github.com/slundberg/shap/issues/1406
45-
shap.explainers._deep.deep_tf.op_handlers[
46-
"AddV2"
47-
] = shap.explainers._deep.deep_tf.passthrough
44+
shap.explainers._deep.deep_tf.op_handlers["AddV2"] = (
45+
shap.explainers._deep.deep_tf.passthrough
46+
)
4847

4948
# Load the trained model
5049
model = tf.keras.models.model_from_json(open("nn_model_sherlock.json").read())
@@ -66,7 +65,7 @@ def update_sample(samples, N, sample):
6665
# Use SHAP to create a summary plot
6766
e = shap.DeepExplainer(model, matrix)
6867
shap_values = e.shap_values(sample)
69-
feature_names = [l.strip() for l in open("pattern_ids.txt")]
68+
feature_names = [line.strip() for line in open("pattern_ids.txt")]
7069
shap.summary_plot(
7170
shap_values, sample, class_names=class_names, feature_names=feature_names
7271
)

preprocess.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
22
import ast
3-
import itertools
43
import math
5-
import json
64
import numpy as np
75
import os
86
import pickle
@@ -12,10 +10,6 @@
1210
from pyarrow.parquet import ParquetFile
1311
from tqdm import tqdm
1412
import hyperscan
15-
import joblib
16-
import numpy as np
17-
import scipy
18-
import scipy.sparse
1913

2014

2115
BATCH_SIZE = 1000

test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747

4848
y_pred = model.predict(matrix)
4949
y_pred = np.argmax(y_pred, axis=1)
50-
labels_pred[
51-
batch * BATCH_SIZE : batch * BATCH_SIZE + len(matrix)
52-
] = le.inverse_transform(y_pred)
50+
labels_pred[batch * BATCH_SIZE : batch * BATCH_SIZE + len(matrix)] = (
51+
le.inverse_transform(y_pred)
52+
)
5353
batch += 1
5454
pbar.update(len(matrix))
5555

0 commit comments

Comments
 (0)