@@ -27,90 +27,6 @@ array_any_nonzero(PyArrayObject *mp);
2727 we fill it in here so that PySequence_XXXX calls work as expected
2828*/
2929
30-
31- static PyObject *
32- array_slice (PyArrayObject * self , Py_ssize_t ilow , Py_ssize_t ihigh )
33- {
34- PyArrayObject * ret ;
35- PyArray_Descr * dtype ;
36- Py_ssize_t dim0 ;
37- char * data ;
38- npy_intp shape [NPY_MAXDIMS ];
39-
40- if (PyArray_NDIM (self ) == 0 ) {
41- PyErr_SetString (PyExc_ValueError , "cannot slice a 0-d array" );
42- return NULL ;
43- }
44-
45- dim0 = PyArray_DIM (self , 0 );
46- if (ilow < 0 ) {
47- ilow = 0 ;
48- }
49- else if (ilow > dim0 ) {
50- ilow = dim0 ;
51- }
52- if (ihigh < ilow ) {
53- ihigh = ilow ;
54- }
55- else if (ihigh > dim0 ) {
56- ihigh = dim0 ;
57- }
58-
59- data = PyArray_DATA (self );
60- if (ilow < ihigh ) {
61- data += ilow * PyArray_STRIDE (self , 0 );
62- }
63-
64- /* Same shape except dimension 0 */
65- shape [0 ] = ihigh - ilow ;
66- memcpy (shape + 1 , PyArray_DIMS (self ) + 1 ,
67- (PyArray_NDIM (self )- 1 )* sizeof (npy_intp ));
68-
69- dtype = PyArray_DESCR (self );
70- Py_INCREF (dtype );
71- ret = (PyArrayObject * )PyArray_NewFromDescr (Py_TYPE (self ), dtype ,
72- PyArray_NDIM (self ), shape ,
73- PyArray_STRIDES (self ), data ,
74- PyArray_FLAGS (self ),
75- (PyObject * )self );
76- if (ret == NULL ) {
77- return NULL ;
78- }
79- Py_INCREF (self );
80- if (PyArray_SetBaseObject (ret , (PyObject * )self ) < 0 ) {
81- Py_DECREF (ret );
82- return NULL ;
83- }
84- PyArray_UpdateFlags (ret , NPY_ARRAY_UPDATE_ALL );
85-
86- return (PyObject * )ret ;
87- }
88-
89-
90- static int
91- array_assign_slice (PyArrayObject * self , Py_ssize_t ilow ,
92- Py_ssize_t ihigh , PyObject * v ) {
93- int ret ;
94- PyArrayObject * tmp ;
95-
96- if (v == NULL ) {
97- PyErr_SetString (PyExc_ValueError ,
98- "cannot delete array elements" );
99- return -1 ;
100- }
101- if (PyArray_FailUnlessWriteable (self , "assignment destination" ) < 0 ) {
102- return -1 ;
103- }
104- tmp = (PyArrayObject * )array_slice (self , ilow , ihigh );
105- if (tmp == NULL ) {
106- return -1 ;
107- }
108- ret = PyArray_CopyObject (tmp , v );
109- Py_DECREF (tmp );
110-
111- return ret ;
112- }
113-
11430static int
11531array_contains (PyArrayObject * self , PyObject * el )
11632{
@@ -134,9 +50,9 @@ NPY_NO_EXPORT PySequenceMethods array_as_sequence = {
13450 (binaryfunc )NULL , /*sq_concat is handled by nb_add*/
13551 (ssizeargfunc )NULL ,
13652 (ssizeargfunc )array_item ,
137- (ssizessizeargfunc )array_slice ,
138- (ssizeobjargproc )array_assign_item , /*sq_ass_item*/
139- (ssizessizeobjargproc )array_assign_slice , /*sq_ass_slice*/
53+ (ssizessizeargfunc )NULL ,
54+ (ssizeobjargproc )array_assign_item , /*sq_ass_item*/
55+ (ssizessizeobjargproc )NULL , /*sq_ass_slice*/
14056 (objobjproc ) array_contains , /*sq_contains */
14157 (binaryfunc ) NULL , /*sg_inplace_concat */
14258 (ssizeargfunc )NULL ,
0 commit comments