From 85091576e8f45e87ab1ec071b5e793c0de14b825 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 5 May 2023 10:19:55 +0100 Subject: [PATCH] Use nopython mode for all jitting (#165) --- src/cellfinder_core/detect/filters/plane/tile_walker.py | 4 ++-- src/cellfinder_core/detect/filters/volume/ball_filter.py | 8 ++++---- .../detect/filters/volume/structure_detection.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cellfinder_core/detect/filters/plane/tile_walker.py b/src/cellfinder_core/detect/filters/plane/tile_walker.py index 507b8514..afa1a046 100644 --- a/src/cellfinder_core/detect/filters/plane/tile_walker.py +++ b/src/cellfinder_core/detect/filters/plane/tile_walker.py @@ -1,7 +1,7 @@ import math import numpy as np -from numba import jit +from numba import njit class TileWalker: @@ -78,7 +78,7 @@ def mark_bright_tiles(self): self.bright_tiles_mask[mask_x, mask_y] = True -@jit +@njit def is_low_average(tile: np.ndarray, threshold: float) -> bool: """ Return `True` if the average value of *tile* is below *threshold*. diff --git a/src/cellfinder_core/detect/filters/volume/ball_filter.py b/src/cellfinder_core/detect/filters/volume/ball_filter.py index a73f754f..eb3840de 100644 --- a/src/cellfinder_core/detect/filters/volume/ball_filter.py +++ b/src/cellfinder_core/detect/filters/volume/ball_filter.py @@ -1,5 +1,5 @@ import numpy as np -from numba import jit +from numba import njit from cellfinder_core.tools.array_operations import bin_mean_3d from cellfinder_core.tools.geometry import make_sphere @@ -196,7 +196,7 @@ def walk(self) -> None: # Highly optimised because most time critical ) -@jit(nopython=True, cache=True) +@njit(cache=True) def _cube_overlaps( cube: np.ndarray, overlap_threshold: float, @@ -246,7 +246,7 @@ def _cube_overlaps( return current_overlap_value > overlap_threshold -@jit(nopython=True) +@njit def _is_tile_to_check( x: int, y: int, @@ -263,7 +263,7 @@ def _is_tile_to_check( return inside_brain_tiles[x_in_mask, y_in_mask, middle_z] -@jit(nopython=True) +@njit def _walk( max_height: int, max_width: int, diff --git a/src/cellfinder_core/detect/filters/volume/structure_detection.py b/src/cellfinder_core/detect/filters/volume/structure_detection.py index 8c81b5ee..499aa230 100644 --- a/src/cellfinder_core/detect/filters/volume/structure_detection.py +++ b/src/cellfinder_core/detect/filters/volume/structure_detection.py @@ -2,7 +2,7 @@ from typing import List, Sequence, Tuple, Union import numpy as np -from numba import jit +from numba import njit from numba.core import types from numba.experimental import jitclass from numba.typed import Dict @@ -16,7 +16,7 @@ class Point: z: int -@jit(nopython=True) +@njit def get_non_zero_dtype_min(values: np.ndarray) -> int: """ Get the minimum of non-zero entries in *values*. @@ -31,7 +31,7 @@ def get_non_zero_dtype_min(values: np.ndarray) -> int: return min_val -@jit(nopython=True) +@njit def traverse_dict(d: dict, a): """ Traverse d, until a is not present as a key. @@ -278,7 +278,7 @@ def structures_to_cells(self) -> List[Point]: return cell_centres -@jit +@njit def is_new_structure(neighbour_ids): for i in range(len(neighbour_ids)): if neighbour_ids[i] != 0: