Skip to content

Commit 60c7dcb

Browse files
authored
Merge pull request #43 from mortacious/fix/minmax
fixed _np_max function using np.amin internally
2 parents 37f98f6 + 19867a3 commit 60c7dcb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

numba_kdtree/kd_tree.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from numba.core import types, cgutils
66
from numba.experimental import structref
7-
from numba.extending import overload_method, intrinsic
7+
from numba.extending import overload_method, intrinsic, overload_attribute
88
from .ckdtree import ckdtree as ckdtree_ct
99
import warnings
1010
from typing import Optional, Any
@@ -65,7 +65,7 @@ def _np_min(array, axis):
6565

6666
@nb.njit(nogil=True, fastmath=True, cache=True, inline='always')
6767
def _np_max(array, axis):
68-
return _np_apply_along_axis(np.amin, axis, array)
68+
return _np_apply_along_axis(np.amax, axis, array)
6969

7070

7171
def _convert_to_valid_input(X, n_features, dtype):
@@ -251,12 +251,12 @@ def _KDTree_get_idx(self):
251251

252252
@nb.njit(cache=True)
253253
def _KDTree_get_size(self):
254-
return self._size()
254+
return self.size
255255

256256

257257
@nb.njit(cache=True)
258258
def _KDTree_get_leafsize(self):
259-
return self._leafsize()
259+
return self.leafsize
260260

261261

262262
@nb.njit(cache=True)
@@ -285,21 +285,21 @@ def _KDTree_query_radius_parallel(self, X, r, p=2.0, eps=0.0, return_sorted=Fals
285285

286286

287287
# functions required for pickling the Kdtree
288-
@overload_method(KDTreeNumbaType, "_size", jit_options={"cache": True})
288+
@overload_attribute(KDTreeNumbaType, "size", jit_options={"cache": True})
289289
def _ol_size(self):
290290
dtype = self.field_dict['data'].dtype
291291
if dtype != nb.types.float32:
292292
dtype = nb.types.float64
293293

294294
func_size = ckdtree_ct.size[dtype]
295295

296-
def _size_impl(self):
296+
def size_impl(self):
297297
return func_size(self.ckdtree)
298298

299-
return _size_impl
299+
return size_impl
300300

301301

302-
@overload_method(KDTreeNumbaType, "_leafsize", jit_options={"cache": True})
302+
@overload_attribute(KDTreeNumbaType, "_leafsize", jit_options={"cache": True})
303303
def _ol_leafsize(self):
304304
"""Returns the leaf size of the underlying tree
305305
"""

0 commit comments

Comments
 (0)