Skip to content

Commit 8cfd2af

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 486a60f commit 8cfd2af

7 files changed

Lines changed: 13 additions & 11 deletions

File tree

elk/extraction/extraction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions for extracting the hidden states of a model."""
2+
23
import os
34
from collections import defaultdict
45
from dataclasses import InitVar, dataclass, replace

elk/metrics/eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def evaluate_preds(
7373
Returns:
7474
dict: A dictionary containing the accuracy, AUROC, and ECE.
7575
"""
76-
(n, v) = y_logits.shape
76+
n, v = y_logits.shape
7777
assert y_true.shape == (n,)
7878

7979
if ensembling == "full":

elk/plotting/visualize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def render(
7878
y=dataset_data["auroc_estimate"],
7979
mode="lines",
8080
name=ensemble,
81-
showlegend=False
82-
if dataset_name != unique_datasets[0]
83-
else True,
81+
showlegend=(
82+
False if dataset_name != unique_datasets[0] else True
83+
),
8484
line=dict(color=color_map[ensemble]),
8585
),
8686
row=row,

elk/promptsource/templates.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ def _escape_pipe(cls, example):
215215
# Replaces any occurrences of the "|||" separator in the example, which
216216
# which will be replaced back after splitting
217217
protected_example = {
218-
key: value.replace("|||", cls.pipe_protector)
219-
if isinstance(value, str)
220-
else value
218+
key: (
219+
value.replace("|||", cls.pipe_protector)
220+
if isinstance(value, str)
221+
else value
222+
)
221223
for key, value in example.items()
222224
}
223225
return protected_example

elk/training/platt_scaling.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class PlattMixin(ABC):
1212
scale: nn.Parameter
1313

1414
@abstractmethod
15-
def __call__(self, *args: Any, **kwds: Any) -> Any:
16-
...
15+
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
1716

1817
def platt_scale(self, labels: Tensor, hiddens: Tensor, max_iter: int = 100):
1918
"""Fit the scale and bias terms to data with LBFGS.

elk/training/supervised.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def train_supervised(
2121
leace = None
2222

2323
for train_data in data.values():
24-
(n, v, d) = train_data.hiddens.shape
24+
n, v, d = train_data.hiddens.shape
2525
train_h = rearrange(train_data.hiddens, "n v d -> (n v) d")
2626

2727
if erase_paraphrases and v > 1:

elk/training/train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def apply_to_layer(
6464
val_dict = self.prepare_data(device, layer, "val")
6565

6666
first_train_data, *rest = train_dict.values()
67-
(_, v, d) = first_train_data.hiddens.shape
67+
_, v, d = first_train_data.hiddens.shape
6868
if not all(other_data.hiddens.shape[-1] == d for other_data in rest):
6969
raise ValueError("All datasets must have the same hidden state size")
7070

0 commit comments

Comments
 (0)