Skip to content

Commit 41b9964

Browse files
committed
Fix ruff errors
1 parent 12b821f commit 41b9964

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

test/quicktest/common.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import logging
2-
import math
3-
from collections.abc import Iterable
42
from functools import lru_cache
53
from pathlib import Path
64
from typing import cast
@@ -107,7 +105,7 @@ def threshold(self, label_or_key: int | str) -> tuple[str, float]:
107105
"""
108106
if isinstance(label_or_key, str):
109107
return label_or_key, self.config["thresholds"][label_or_key]
110-
elif isinstance(label_or_key, (int, np.integer)):
108+
elif isinstance(label_or_key, int | np.integer):
111109
labelname = ""
112110
try:
113111
labelname = self.mapper[label_or_key]

test/quicktest/helper.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Iterable
2+
from collections.abc import Iterable
33

44
import numpy as np
55
import pytest
@@ -12,7 +12,6 @@ def assert_same_headers(expected_header, actual_header):
1212
# Get the image headers
1313

1414
from nibabel.cmdline.diff import get_headers_diff
15-
from nibabel import analyze
1615

1716
# Check the image headers
1817
header_diff = get_headers_diff([actual_header, expected_header])
@@ -116,6 +115,9 @@ def _compare_numpy(self, actual: np.ndarray) -> list[str]:
116115
msg.append("Connected components exceeding threshold:")
117116
connected_components = regionprops(delta_where)
118117
msg.extend(f" {i}: {cc.area} voxels @{cc.centroid}" for i, cc in enumerate(connected_components[:5]))
118+
except BaseException as e:
119+
logger.exception(e)
120+
msg.append(f"Exception while comparing arrays: {e}")
119121
finally:
120122
return msg
121123

test/quicktest/test_images.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
from collections import OrderedDict
21
from functools import lru_cache
32
from logging import getLogger
43
from pathlib import Path
54

6-
import nibabel.cmdline.diff
75
import numpy as np
86
import pytest
97
import yaml
108

119
from FastSurferCNN.utils.metrics import dice_score
1210

1311
from .common import SubjectDefinition, Tolerances, write_table_file
14-
from .helper import assert_same_headers, Approx
12+
from .helper import Approx, assert_same_headers
1513

1614
logger = getLogger(__name__)
1715

test/quicktest/test_stats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import numpy as np
66
import pytest
7-
from numpy import number
87

98
from FastSurferCNN.segstats import PVStats
109

@@ -312,7 +311,8 @@ def filter_keys(stats: PVStats) -> dict[str, int | float]:
312311
expected_conflicts.append(expected)
313312

314313
if delta_dir:
315-
from typing import TypeVar, Hashable
314+
from collections.abc import Hashable
315+
from typing import TypeVar
316316
_T = TypeVar("_T", bound=Hashable)
317317

318318
def relative(a: dict[_T, int | float], b: dict[_T, int | float], field: _T) -> float:

0 commit comments

Comments
 (0)