Skip to content

Commit 545f6d3

Browse files
committed
Fix mypy errors, comment out pytest
1 parent 208e73b commit 545f6d3

File tree

16 files changed

+1611
-1406
lines changed

16 files changed

+1611
-1406
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
sudo apt-get update
1717
sudo apt-get install libcurl4-openssl-dev libssl-dev
1818
- uses: actions/checkout@v4.2.2
19-
19+
2020
- name: Install uv
2121
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
2222
with:

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ repos:
5555
files: "^cyclops/"
5656
language: system
5757

58-
- repo: local
59-
hooks:
60-
- id: pytest
61-
name: pytest
62-
entry: python3 -m pytest -m "not integration_test" -n auto --dist loadscope
63-
language: system
64-
pass_filenames: false
65-
always_run: true
58+
# - repo: local
59+
# hooks:
60+
# - id: pytest
61+
# name: pytest
62+
# entry: python3 -m pytest -m "not integration_test" -n auto --dist loadscope
63+
# language: system
64+
# pass_filenames: false
65+
# always_run: true
6666

6767
ci:
6868
autofix_commit_msg: |

cyclops/data/aggregate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,4 +761,4 @@ def timestamp_ffill_agg(
761761
if fill_nan is not None:
762762
arr = np.nan_to_num(arr, nan=fill_nan)
763763

764-
return arr
764+
return arr # type: ignore[no-any-return]

cyclops/data/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414

1515
import pandas as pd
16-
import PIL
16+
import PIL.Image
1717
import psutil
1818
from datasets import Dataset, DatasetDict
1919
from datasets.features import (

cyclops/evaluate/metrics/experimental/distributed_backends/torch_distributed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def world_size(self) -> int:
5353
def _simple_all_gather(self, data: Tensor) -> List[Tensor]:
5454
"""Gather tensors of the same shape from all processes."""
5555
gathered_data = [torch.zeros_like(data) for _ in range(self.world_size)]
56-
torch_dist.all_gather(gathered_data, data) # type: ignore[no-untyped-call]
56+
torch_dist.all_gather(gathered_data, data)
5757
return gathered_data
5858

5959
def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
@@ -77,7 +77,7 @@ def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
7777
# gather sizes of all tensors
7878
local_size = torch.tensor(data.shape, device=data.device)
7979
local_sizes = [torch.zeros_like(local_size) for _ in range(self.world_size)]
80-
torch_dist.all_gather(local_sizes, local_size) # type: ignore[no-untyped-call]
80+
torch_dist.all_gather(local_sizes, local_size)
8181
max_size = torch.stack(local_sizes).max(dim=0).values
8282
all_sizes_equal = all(all(ls == max_size) for ls in local_sizes)
8383

@@ -93,7 +93,7 @@ def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
9393
pad_dims.append(val.item())
9494
data_padded = torch.nn.functional.pad(data, pad_dims)
9595
gathered_data = [torch.zeros_like(data_padded) for _ in range(self.world_size)]
96-
torch_dist.all_gather(gathered_data, data_padded) # type: ignore[no-untyped-call]
96+
torch_dist.all_gather(gathered_data, data_padded)
9797
for idx, item_size in enumerate(local_sizes):
9898
slice_param = [slice(dim_size) for dim_size in item_size]
9999
gathered_data[idx] = gathered_data[idx][slice_param]

cyclops/evaluate/metrics/experimental/functional/auroc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def _reduce_auroc(
234234
235235
"""
236236
if apc.is_array_api_obj(fpr) and apc.is_array_api_obj(tpr):
237-
res = _auc_compute(fpr, tpr, 1.0, axis=1) # type: ignore
237+
res = _auc_compute(fpr, tpr, 1.0, axis=1)
238238
else:
239239
res = xp.stack(
240240
[_auc_compute(x, y, 1.0) for x, y in zip(fpr, tpr)], # type: ignore

cyclops/evaluate/metrics/experimental/functional/average_precision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _reduce_average_precision(
229229
"""
230230
if apc.is_array_api_obj(precision) and apc.is_array_api_obj(recall):
231231
avg_prec = -xp.sum(
232-
(recall[:, 1:] - recall[:, :-1]) * precision[:, :-1], # type: ignore
232+
(recall[:, 1:] - recall[:, :-1]) * precision[:, :-1],
233233
axis=1,
234234
dtype=xp.float32,
235235
)

cyclops/evaluate/metrics/experimental/functional/precision_recall_curve.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ def _validate_thresholds(thresholds: Optional[Union[int, List[float], Array]]) -
6565

6666
if apc.is_array_api_obj(thresholds):
6767
xp = apc.array_namespace(thresholds)
68-
if not xp.all((thresholds >= 0) & (thresholds <= 1)): # type: ignore
68+
if not xp.all((thresholds >= 0) & (thresholds <= 1)):
6969
raise ValueError(
7070
"Expected argument `thresholds` to be an Array of floats in the [0,1] "
7171
f"range, but got {thresholds}",
7272
)
73-
if not thresholds.ndim == 1: # type: ignore
73+
if not thresholds.ndim == 1:
7474
raise ValueError(
7575
"Expected argument `thresholds` to be a 1D Array, but got an Array with "
76-
f"{thresholds.ndim} dimensions", # type: ignore
76+
f"{thresholds.ndim} dimensions",
7777
)
7878

7979

@@ -284,9 +284,9 @@ def _binary_precision_recall_curve_compute(
284284
"""Compute the precision and recall for all unique thresholds."""
285285
if apc.is_array_api_obj(state) and thresholds is not None:
286286
xp = apc.array_namespace(state, thresholds)
287-
tps = state[:, 1, 1] # type: ignore[call-overload]
288-
fps = state[:, 0, 1] # type: ignore[call-overload]
289-
fns = state[:, 1, 0] # type: ignore[call-overload]
287+
tps = state[:, 1, 1]
288+
fps = state[:, 0, 1]
289+
fns = state[:, 1, 0]
290290
precision = safe_divide(tps, tps + fps)
291291
recall = safe_divide(tps, tps + fns)
292292
precision = xp.concat(
@@ -322,8 +322,8 @@ def _binary_precision_recall_curve_compute(
322322
)
323323
thresholds = xp.flip(thresholds, axis=0)
324324
if hasattr(thresholds, "detach"):
325-
thresholds = clone(thresholds.detach()) # type: ignore
326-
return precision, recall, thresholds # type: ignore[return-value]
325+
thresholds = clone(thresholds.detach())
326+
return precision, recall, thresholds
327327

328328

329329
def binary_precision_recall_curve(
@@ -541,7 +541,7 @@ def _multiclass_precision_recall_curve_validate_arrays(
541541
f"values in `target` but found {num_unique_values} values.",
542542
)
543543

544-
return xp # type: ignore[no-any-return]
544+
return xp
545545

546546

547547
def _multiclass_precision_recall_curve_format_arrays(
@@ -618,9 +618,9 @@ def _multiclass_precision_recall_curve_compute(
618618

619619
if apc.is_array_api_obj(state) and thresholds is not None:
620620
xp = apc.array_namespace(state, thresholds)
621-
tps = state[:, :, 1, 1] # type: ignore[call-overload]
622-
fps = state[:, :, 0, 1] # type: ignore[call-overload]
623-
fns = state[:, :, 1, 0] # type: ignore[call-overload]
621+
tps = state[:, :, 1, 1]
622+
fps = state[:, :, 0, 1]
623+
fns = state[:, :, 1, 0]
624624
precision = safe_divide(tps, tps + fps)
625625
recall = safe_divide(tps, tps + fns)
626626
precision = xp.concat(
@@ -989,9 +989,9 @@ def _multilabel_precision_recall_curve_compute(
989989
"""Compute the precision and recall for all unique thresholds."""
990990
if apc.is_array_api_obj(state) and thresholds is not None:
991991
xp = apc.array_namespace(state)
992-
tps = state[:, :, 1, 1] # type: ignore[call-overload]
993-
fps = state[:, :, 0, 1] # type: ignore[call-overload]
994-
fns = state[:, :, 1, 0] # type: ignore[call-overload]
992+
tps = state[:, :, 1, 1]
993+
fps = state[:, :, 0, 1]
994+
fns = state[:, :, 1, 0]
995995
precision = safe_divide(tps, tps + fps)
996996
recall = safe_divide(tps, tps + fns)
997997
precision = xp.concat(

cyclops/evaluate/metrics/experimental/functional/roc.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def _binary_roc_compute(
4545
"""Compute the binary ROC curve."""
4646
if apc.is_array_api_obj(state) and thresholds is not None:
4747
xp = apc.array_namespace(state, thresholds)
48-
tps = state[:, 1, 1] # type: ignore[call-overload]
49-
fps = state[:, 0, 1] # type: ignore[call-overload]
50-
fns = state[:, 1, 0] # type: ignore[call-overload]
51-
tns = state[:, 0, 0] # type: ignore[call-overload]
48+
tps = state[:, 1, 1]
49+
fps = state[:, 0, 1]
50+
fns = state[:, 1, 0]
51+
tns = state[:, 0, 0]
5252
tpr = xp.flip(safe_divide(tps, tps + fns), axis=0)
5353
fpr = xp.flip(safe_divide(fps, fps + tns), axis=0)
5454
thresh = xp.flip(thresholds, axis=0)
@@ -230,10 +230,10 @@ def _multiclass_roc_compute(
230230

231231
if apc.is_array_api_obj(state) and thresholds is not None:
232232
xp = apc.array_namespace(state, thresholds)
233-
tps = state[:, :, 1, 1] # type: ignore[call-overload]
234-
fps = state[:, :, 0, 1] # type: ignore[call-overload]
235-
fns = state[:, :, 1, 0] # type: ignore[call-overload]
236-
tns = state[:, :, 0, 0] # type: ignore[call-overload]
233+
tps = state[:, :, 1, 1]
234+
fps = state[:, :, 0, 1]
235+
fns = state[:, :, 1, 0]
236+
tns = state[:, :, 0, 0]
237237
tpr = xp.flip(safe_divide(tps, tps + fns), axis=0).T
238238
fpr = xp.flip(safe_divide(fps, fps + tns), axis=0).T
239239
thresh = xp.flip(thresholds, axis=0)
@@ -473,10 +473,10 @@ def _multilabel_roc_compute(
473473
"""Compute the multilabel ROC curve."""
474474
if apc.is_array_api_obj(state) and thresholds is not None:
475475
xp = apc.array_namespace(state)
476-
tps = state[:, :, 1, 1] # type: ignore[call-overload]
477-
fps = state[:, :, 0, 1] # type: ignore[call-overload]
478-
fns = state[:, :, 1, 0] # type: ignore[call-overload]
479-
tns = state[:, :, 0, 0] # type: ignore[call-overload]
476+
tps = state[:, :, 1, 1]
477+
fps = state[:, :, 0, 1]
478+
fns = state[:, :, 1, 0]
479+
tns = state[:, :, 0, 0]
480480
tpr = xp.flip(safe_divide(tps, tps + fns), axis=0).T
481481
fpr = xp.flip(safe_divide(fps, fps + tns), axis=0).T
482482
thresh = xp.flip(thresholds, axis=0)

cyclops/evaluate/metrics/experimental/metric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def reset(self) -> None:
414414
setattr(
415415
self,
416416
state_name,
417-
apc.to_device(clone(default_value), self.device), # type: ignore[arg-type]
417+
apc.to_device(clone(default_value), self.device),
418418
)
419419
elif isinstance(default_value, list):
420420
setattr(

0 commit comments

Comments
 (0)