From 45f23ebc82426b3a4569377a04bb2747c447c2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20V=C3=B6r=C3=B6s?= Date: Sat, 14 Sep 2024 11:38:04 +0200 Subject: [PATCH] Roll fix (#687) * fix roll, when shift is 0 --- code/numpy/numerical.c | 8 +++++++- code/ulab.c | 2 +- docs/ulab-change-log.md | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/code/numpy/numerical.c b/code/numpy/numerical.c index 68cf44dd..0961e3c0 100644 --- a/code/numpy/numerical.c +++ b/code/numpy/numerical.c @@ -1186,13 +1186,19 @@ mp_obj_t numerical_roll(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar mp_raise_TypeError(MP_ERROR_TEXT("roll argument must be an ndarray")); } ndarray_obj_t *ndarray = MP_OBJ_TO_PTR(args[0].u_obj); - uint8_t *array = ndarray->array; ndarray_obj_t *results = ndarray_new_dense_ndarray(ndarray->ndim, ndarray->shape, ndarray->dtype); int32_t shift = mp_obj_get_int(args[1].u_obj); + + if(shift == 0) { + ndarray_copy_array(ndarray, results, 0); + return MP_OBJ_FROM_PTR(results); + } + int32_t _shift = shift < 0 ? -shift : shift; size_t counter; + uint8_t *array = ndarray->array; uint8_t *rarray = (uint8_t *)results->array; if(args[2].u_obj == mp_const_none) { // roll the flattened array diff --git a/code/ulab.c b/code/ulab.c index 24776986..948d621f 100644 --- a/code/ulab.c +++ b/code/ulab.c @@ -33,7 +33,7 @@ #include "user/user.h" #include "utils/utils.h" -#define ULAB_VERSION 6.5.3 +#define ULAB_VERSION 6.5.4 #define xstr(s) str(s) #define str(s) #s diff --git a/docs/ulab-change-log.md b/docs/ulab-change-log.md index 9f885936..90b86307 100644 --- a/docs/ulab-change-log.md +++ b/docs/ulab-change-log.md @@ -1,3 +1,9 @@ +Sat, 14 Sep 2024 + +version 6.5.4 + + fix roll, when shift is 0 + Wed, 6 Mar 2024 version 6.5.2