Skip to content

Commit 831c940

Browse files
committed
py38
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
1 parent b3a44f4 commit 831c940

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

monai/metrics/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import annotations
1313

1414
import warnings
15-
from functools import cache
15+
from functools import lru_cache
1616
from typing import Any, Sequence
1717

1818
import numpy as np
@@ -374,7 +374,7 @@ def prepare_spacing(
374374
ENCODING_KERNEL = {2: [[8, 4], [2, 1]], 3: [[[128, 64], [32, 16]], [[8, 4], [2, 1]]]}
375375

376376

377-
@cache
377+
@lru_cache(maxsize=None)
378378
def _get_neighbour_code_to_normals_table(device=None):
379379
"""
380380
returns a lookup table. For every binary neighbour code (2x2x2 neighbourhood = 8 neighbours = 8 bits = 256 codes)
@@ -657,14 +657,13 @@ def create_table_neighbour_code_to_surface_area(spacing_mm, device=None):
657657
658658
Args:
659659
spacing_mm: a sequence of 3 numbers. Voxel spacing along the first 3 spatial axes.
660-
deivce: device to put the table on.
660+
device: device to put the table on.
661661
662662
Returns:
663663
An array of size 256, mapping neighbourhood code to the surface area.
664664
ENCODING_KERNEL[3] which is the kernel used to compute the neighbourhood code.
665665
"""
666-
# compute the area for all 256 possible surface elements given a 2x2x2 neighbourhood) according to the spacing_mm
667-
neighbour_code_to_surface_area = np.zeros([256])
666+
# compute the area for all 256 possible surface elements given a 2x2x2 neighbourhood according to the spacing_mm
668667
c = _get_neighbour_code_to_normals_table(device)
669668
s = torch.as_tensor(
670669
[[[spacing_mm[1] * spacing_mm[2], spacing_mm[0] * spacing_mm[2], spacing_mm[0] * spacing_mm[1]]]],

0 commit comments

Comments
 (0)