fixed slicing error
This commit is contained in:
parent
0bfba3bf1b
commit
ddd553f76f
2 changed files with 1 additions and 4 deletions
|
|
@ -920,7 +920,6 @@ static size_t slice_length(mp_bound_slice_t slice) {
|
|||
}
|
||||
|
||||
static mp_bound_slice_t generate_slice(mp_int_t n, mp_obj_t index) {
|
||||
// micropython seems to have difficulties with negative steps
|
||||
mp_bound_slice_t slice;
|
||||
if(MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
||||
mp_obj_slice_indices(index, n, &slice);
|
||||
|
|
@ -959,7 +958,7 @@ ndarray_obj_t *ndarray_view_from_slices(ndarray_obj_t *ndarray, mp_obj_tuple_t *
|
|||
offset += ndarray->strides[ULAB_MAX_DIMS - ndim + i] * (int32_t)slice.start;
|
||||
strides[ULAB_MAX_DIMS - ndim + i] = (int32_t)slice.step * ndarray->strides[ULAB_MAX_DIMS - ndim + i];
|
||||
}
|
||||
return ndarray_new_view(ndarray, ndim-tuple->len, shape, strides, offset);
|
||||
return ndarray_new_view(ndarray, ndim, shape, strides, offset);
|
||||
}
|
||||
|
||||
void ndarray_assign_view(ndarray_obj_t *view, ndarray_obj_t *values) {
|
||||
|
|
|
|||
|
|
@ -13,10 +13,8 @@ for num in range(1,4):
|
|||
ll = len(sl)
|
||||
try:
|
||||
sa = list(a[start:end:stride])
|
||||
la = len(sa)
|
||||
except IndexError as e:
|
||||
sa = str(e)
|
||||
la = -1
|
||||
print("%2d [% d:% d:% d] %-24r %-24r%s" % (
|
||||
num, start, end, stride, sl, sa, " ***" if sa != sl else ""))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue