Skip to content

Commit e2a0005

Browse files
committed
progress
1 parent ad5720e commit e2a0005

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/_arraykit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3354,9 +3354,12 @@ slice_to_ascending_slice(PyObject *Py_UNUSED(m), PyObject *args) {
33543354
&start,
33553355
&stop,
33563356
step);
3357+
// AK_DEBUG_MSG_OBJ("resolved slice", Py_BuildValue("nnnn", pos, stop, step, len));
3358+
3359+
// real stop is (len-1); len is negative
33573360

3358-
PyObject* asc_start = PyLong_FromSsize_t(stop + 1);
33593361
PyObject* asc_stop = PyLong_FromSsize_t(start + 1);
3362+
PyObject* asc_start = PyLong_FromSsize_t(start + (step * (len - 1)));
33603363
PyObject* asc_step = PyLong_FromSsize_t(-step);
33613364

33623365
// might be NULL, let return

test/test_util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,11 @@ def test_slice_to_ascending_slice_c(self) -> None:
724724
with self.assertRaises(TypeError):
725725
_ = slice_to_ascending_slice(slice(1, 4), 'x')
726726

727-
727+
def test_slice_to_ascending_slice_d(self) -> None:
728+
self.assertEqual(slice_to_ascending_slice(
729+
slice(10, 2, -2), 12),
730+
slice(4, 11, 2),
731+
)
728732

729733
if __name__ == '__main__':
730734
unittest.main()

0 commit comments

Comments
 (0)