Skip to content

Commit 6e7cf2c

Browse files
committed
functools.cache (added in Python 3.9) is a convenience alias for functools.lru_cache(maxsize=None). Functionally they are the same when lru_cache is used with maxsize=None.
Signed-off-by: jirka <jirka.borovec@seznam.cz>
1 parent 2d0014a commit 6e7cf2c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

monai/metrics/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import warnings
1515
from collections.abc import Iterable, Sequence
16-
from functools import lru_cache, partial
16+
from functools import partial, cache
1717
from types import ModuleType
1818
from typing import Any
1919

@@ -465,7 +465,7 @@ def prepare_spacing(
465465
ENCODING_KERNEL = {2: [[8, 4], [2, 1]], 3: [[[128, 64], [32, 16]], [[8, 4], [2, 1]]]}
466466

467467

468-
@lru_cache(maxsize=None)
468+
@cache
469469
def _get_neighbour_code_to_normals_table(device=None):
470470
"""
471471
returns a lookup table. For every binary neighbour code (2x2x2 neighbourhood = 8 neighbours = 8 bits = 256 codes)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ select = [
4747
"E", "F", "W", # flake8
4848
"NPY", # NumPy specific rules
4949
"UP", # pyupgrade
50-
"RUF100", # aka yesqa
50+
# "RUF100", # aka yesqa
5151
]
5252
extend-ignore = [
5353
"E741", # ambiguous variable name

tests/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def __init__(self, *args, **kwargs):
3232
super().__init__(*args, **kwargs)
3333
self.timed_tests = {}
3434

35-
def startTest(self, test): # NOQA: N802
35+
def startTest(self, test): # noqa: N802
3636
"""Start timer, print test name, do normal test."""
3737
self.start_time = time.time()
3838
name = self.getDescription(test)
3939
self.stream.write(f"Starting test: {name}...\n")
4040
super().startTest(test)
4141

42-
def stopTest(self, test): # NOQA: N802
42+
def stopTest(self, test): # noqa: N802
4343
"""On test end, get time, print, store and do normal behaviour."""
4444
elapsed = time.time() - self.start_time
4545
name = self.getDescription(test)

0 commit comments

Comments
 (0)