Skip to content

Commit 5dc8c88

Browse files
Merge pull request #163 from StingraySoftware/fix_array_take
Numba now supports array np.take, we remove this conflicting overload
2 parents 8990b80 + 9efd168 commit 5dc8c88

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

hendrics/compat/compatibility.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from functools import wraps
2+
import warnings
23
import numpy as np
34
from astropy import log
45
from collections.abc import Iterable as iterable
@@ -9,20 +10,6 @@
910
from numba import types
1011
from numba.extending import overload_method
1112

12-
@overload_method(types.Array, "take") # pragma: no cover
13-
def array_take(arr, indices):
14-
"""Adapt np.take to arrays"""
15-
if isinstance(indices, types.Array):
16-
17-
def take_impl(arr, indices):
18-
n = indices.shape[0]
19-
res = np.empty(n, arr.dtype)
20-
for i in range(n):
21-
res[i] = arr[indices[i]]
22-
return res
23-
24-
return take_impl
25-
2613
HAS_NUMBA = True
2714
except ImportError:
2815
HAS_NUMBA = False
@@ -57,6 +44,8 @@ def __call__(self, func):
5744

5845
float32 = float64 = int32 = int64 = lambda x, y: None
5946

60-
def array_take(arr, indices):
61-
"""Adapt np.take to arrays"""
62-
return np.take(arr, indices)
47+
48+
def array_take(arr, indices): # pragma: no cover
49+
"""Adapt np.take to arrays"""
50+
warnings.warn("array_take is deprecated. Use np.take instead, also with Numba.")
51+
return np.take(arr, indices)

0 commit comments

Comments
 (0)