You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Weird exception when slicing an array with non-trivial step #46606
Slices with step not equal to 1 (or None) will produce a copy
rather than a zero-copy view
"""
cdef:
Py_ssize_t start, stop, step
Py_ssize_t n =len(arrow_obj)
start, stop, step = key.indices(n)
if step !=1:
indices = np.arange(start, stop, step)
return arrow_obj.take(indices)
else:
length =max(stop - start, 0)
return arrow_obj.slice(start, length)
so that it doesn't use numpy. We could use list(range(start, stop, step)) instead of np.arange(start, stop, step). @thisisnic this could be a nice next issue when/if you have the capacity.
Activity
pitrou commentedon May 27, 2025
cc @AlenkaF @thisisnic
AlenkaF commentedon May 27, 2025
Hm, I get a different behaviour:
pitrou commentedon May 27, 2025
It seems the error happens when NumPy is not installed (
arangeis a NumPy function).(@raulcd FYI)
AlenkaF commentedon May 27, 2025
Ah yes. So the fix would be updating
_normalize_slice:arrow/python/pyarrow/array.pxi
Lines 575 to 591 in a2941dd
so that it doesn't use numpy. We could use
list(range(start, stop, step))instead ofnp.arange(start, stop, step).@thisisnic this could be a nice next issue when/if you have the capacity.
GH-46606: [Python] Do not require numpy when normalizing slice (#46732)
raulcd commentedon Jun 10, 2025
Issue resolved by pull request 46732
#46732
apacheGH-46606: [Python] Do not require numpy when normalizing slice (a…