@@ -63,38 +63,6 @@ static void numerical_reduce_axes(ndarray_obj_t *ndarray, int8_t axis, size_t *s
6363 }
6464}
6565
66- static shape_strides numerical_reduce_axes_ (ndarray_obj_t * ndarray , mp_obj_t axis ) {
67- // TODO: replace numerical_reduce_axes with this function, wherever applicable
68- int8_t ax = mp_obj_get_int (axis );
69- if (ax < 0 ) ax += ndarray -> ndim ;
70- if ((ax < 0 ) || (ax > ndarray -> ndim - 1 )) {
71- mp_raise_ValueError (translate ("index out of range" ));
72- }
73- shape_strides _shape_strides ;
74- _shape_strides .index = ULAB_MAX_DIMS - ndarray -> ndim + ax ;
75- size_t * shape = m_new (size_t , ULAB_MAX_DIMS );
76- memset (shape , 0 , sizeof (size_t )* ULAB_MAX_DIMS );
77- _shape_strides .shape = shape ;
78- int32_t * strides = m_new (int32_t , ULAB_MAX_DIMS );
79- memset (strides , 0 , sizeof (uint32_t )* ULAB_MAX_DIMS );
80- _shape_strides .strides = strides ;
81- if ((ndarray -> ndim == 1 ) && (_shape_strides .axis == 0 )) {
82- _shape_strides .index = 0 ;
83- _shape_strides .shape [ULAB_MAX_DIMS - 1 ] = 1 ;
84- } else {
85- for (uint8_t i = ULAB_MAX_DIMS - 1 ; i > 0 ; i -- ) {
86- if (i > _shape_strides .index ) {
87- _shape_strides .shape [i ] = ndarray -> shape [i ];
88- _shape_strides .strides [i ] = ndarray -> strides [i ];
89- } else {
90- _shape_strides .shape [i ] = ndarray -> shape [i - 1 ];
91- _shape_strides .strides [i ] = ndarray -> strides [i - 1 ];
92- }
93- }
94- }
95- return _shape_strides ;
96- }
97-
9866#if ULAB_NUMPY_HAS_ALL | ULAB_NUMPY_HAS_ANY
9967static mp_obj_t numerical_all_any (mp_obj_t oin , mp_obj_t axis , uint8_t optype ) {
10068 bool anytype = optype == NUMERICAL_ALL ? 1 : 0 ;
@@ -148,7 +116,7 @@ static mp_obj_t numerical_all_any(mp_obj_t oin, mp_obj_t axis, uint8_t optype) {
148116 } while (i < ndarray -> shape [ULAB_MAX_DIMS - 4 ]);
149117 #endif
150118 } else {
151- shape_strides _shape_strides = numerical_reduce_axes_ (ndarray , axis );
119+ shape_strides _shape_strides = tools_reduce_axes (ndarray , axis );
152120 ndarray_obj_t * results = ndarray_new_dense_ndarray (MAX (1 , ndarray -> ndim - 1 ), _shape_strides .shape , NDARRAY_BOOL );
153121 uint8_t * rarray = (uint8_t * )results -> array ;
154122 if (optype == NUMERICAL_ALL ) {
0 commit comments