Skip to content

Commit 0b4eb93

Browse files
committed
linting
1 parent 754cf81 commit 0b4eb93

31 files changed

+47
-1083
lines changed

.github/workflows/push.yml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
python-version: ${{ matrix.python }}
3333
- run: "python -m pip install -r requirements.in"
3434
- run: "python -m pip install -r requirements-dev.in"
35+
- run: "python -m pip install -r requirements-mgm.in"
3536
- run: "python -m pip install --editable ."
3637
- run: "python -m pytest"
3738
- env:

src/lobster/_imports.py

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from lightning_utilities.core.imports import RequirementCache

src/lobster/data/_calm_datamodule.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from typing import Any, Callable, Iterable, Optional, Sequence, TypeVar, Union
55

66
import torch.utils.data
7-
from lobster.transforms import Transform
87
from lightning import LightningDataModule
98
from torch import Generator
109
from torch.utils.data import DataLoader, Sampler
1110

1211
from lobster.datasets._calm_dataset import CalmDataset
1312
from lobster.tokenization import PmlmTokenizerTransform
13+
from lobster.transforms import Transform
1414

1515
T = TypeVar("T")
1616

src/lobster/data/_cmap_datamodule.py

-293
This file was deleted.

src/lobster/data/_dataframe_dataset_in_memory.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
from typing import Any, Callable, Iterable, Optional, Sequence, TypeVar, Union
33

44
import torch
5-
from lobster.transforms import Transform
65
from lightning import LightningDataModule
76
from pandas import DataFrame
87
from torch import Generator, Tensor
98
from torch.utils.data import DataLoader, Dataset, Sampler
109

10+
from lobster.transforms import Transform
11+
1112
T = TypeVar("T")
1213

1314

@@ -247,9 +248,7 @@ def __getitem__(self, index: int) -> T:
247248
if self._target_transform_fn is not None:
248249
y = self._target_transform_fn(y)
249250

250-
if len(self._target_columns) > 1 and not all(
251-
isinstance(y_val, Tensor) for y_val in y
252-
):
251+
if len(self._target_columns) > 1 and not all(isinstance(y_val, Tensor) for y_val in y):
253252
y = tuple(Tensor(y_val) for y_val in y)
254253

255254
elif not isinstance(y, Tensor):

src/lobster/data/_farthest_first_traversal.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import torch
2-
import edlib
31
import heapq
4-
import numpy as np
52
from typing import Optional
63

4+
import edlib
5+
import numpy as np
6+
import torch
7+
78

89
class FarthestFirstTraversal:
910
def __init__(
@@ -53,10 +54,7 @@ def str_fft(self, inputs: list[str]):
5354
inputs = [inputs[i] for i in perm]
5455
centroids = [inputs[i] for i in range(self._k)]
5556
while len(centroids) < self._num_samples:
56-
dist = [
57-
min(self._levenshtein(str1, str2) for str2 in centroids)
58-
for str1 in inputs
59-
]
57+
dist = [min(self._levenshtein(str1, str2) for str2 in centroids) for str1 in inputs]
6058
farthest = dist.index(max(dist))
6159
if inputs[farthest] in centroids:
6260
break
@@ -82,12 +80,14 @@ def _levenshtein(s1, s2):
8280

8381
return previous_row[-1]
8482

83+
8584
def edit_dist(x: str, y: str):
8685
"""
8786
Computes the edit distance between two strings.
8887
"""
8988
return edlib.align(x, y)["editDistance"]
9089

90+
9191
def ranked_fft(
9292
library: np.ndarray,
9393
ranking_scores: Optional[np.ndarray] = None,
@@ -138,10 +138,7 @@ def ranked_fft(
138138
neg_dist, score, idx, num_checked = heapq.heappop(pq)
139139
# Check if the top of the heap has been checked against all currently selected sequences
140140
if num_checked < len(selected):
141-
min_dist = min(
142-
edit_dist(library[idx], library[selected[i]])
143-
for i in range(num_checked, len(selected))
144-
)
141+
min_dist = min(edit_dist(library[idx], library[selected[i]]) for i in range(num_checked, len(selected)))
145142
min_dist = min(min_dist, -neg_dist)
146143
heapq.heappush(pq, (-min_dist, score, idx, len(selected)))
147144
else:

0 commit comments

Comments
 (0)