Skip to content

Commit ea02688

Browse files
committed
1.3.1 RC 1
1 parent 46d83e1 commit ea02688

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ ArrayKit requires the following:
3535
What is New in ArrayKit
3636
-------------------------
3737

38+
1.3.1
39+
............
40+
41+
Improved ``slice_to_unit()`` integer extraction.
42+
43+
3844
1.3.0
3945
............
4046

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1.3.0
1+
1.3.1
22

src/methods.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ slice_to_unit(PyObject *Py_UNUSED(m), PyObject *a)
8282

8383
Py_ssize_t step = 1;
8484
if (py_step != Py_None) {
85-
step = PyLong_AsSsize_t(py_step);
85+
step = PyNumber_AsSsize_t(py_step, NULL);
8686
if (step == -1 && PyErr_Occurred()) {
8787
return NULL;
8888
}
@@ -93,12 +93,12 @@ slice_to_unit(PyObject *Py_UNUSED(m), PyObject *a)
9393

9494
Py_ssize_t start = 0;
9595
if (py_start != Py_None) {
96-
start = PyLong_AsSsize_t(py_start);
96+
start = PyNumber_AsSsize_t(py_start, NULL);
9797
if (start == -1 && PyErr_Occurred()) {
9898
return NULL;
9999
}
100100
}
101-
Py_ssize_t stop = PyLong_AsSsize_t(py_stop);
101+
Py_ssize_t stop = PyNumber_AsSsize_t(py_stop, NULL);
102102
if (stop == -1 && PyErr_Occurred()) {
103103
return NULL;
104104
}

test/test_util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,13 @@ def test_slice_to_unit_c(self) -> None:
972972
with self.assertRaises(TypeError):
973973
_ = slice_to_unit(3)
974974

975+
def test_slice_to_unit_d(self) -> None:
976+
# __index__-able (NumPy integer) bounds are accepted
977+
self.assertEqual(slice_to_unit(slice(np.int64(3), np.int64(4))), 3)
978+
self.assertEqual(slice_to_unit(slice(np.int64(2), np.int64(4))), -1)
979+
self.assertEqual(slice_to_unit(slice(None, np.int64(1))), 0)
980+
self.assertEqual(slice_to_unit(slice(np.int64(2), np.int64(3), np.int64(1))), 2)
981+
975982

976983
if __name__ == '__main__':
977984
unittest.main()

0 commit comments

Comments
 (0)