Skip to content

Commit b8d1ae3

Browse files
committed
BUGFIX: Fixing the dimension lengths when negative indices are used
1 parent 38ace15 commit b8d1ae3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arrayfire/array.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__ (self, S):
102102
if (S.start is not None):
103103
self.begin = ct.c_double(S.start)
104104
if (S.stop is not None):
105-
self.end = ct.c_double(S.stop - 1) if S.stop >= 0 else ct.c_double(S.stop)
105+
self.end = ct.c_double(S.stop - 1)
106106
if (S.step is not None):
107107
self.step = ct.c_double(S.step)
108108
else:
@@ -134,12 +134,12 @@ def get_indices(key, n_dims):
134134
inds = index_vec()
135135

136136
for n in range(n_dims):
137-
inds[n] = index(slice(0, -1))
137+
inds[n] = index(slice(None))
138138

139139
if isinstance(key, tuple):
140-
num_idx = len(key)
141-
for n in range(n_dims):
142-
inds[n] = index(key[n]) if (n < num_idx) else index(slice(0, -1))
140+
n_idx = len(key)
141+
for n in range(n_idx):
142+
inds[n] = index(key[n])
143143
else:
144144
inds[0] = index(key)
145145

0 commit comments

Comments
 (0)