Skip to content

Commit 45f23eb

Browse files
authored
Roll fix (#687)
* fix roll, when shift is 0
1 parent 1d3ddd8 commit 45f23eb

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

code/numpy/numerical.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,13 +1186,19 @@ mp_obj_t numerical_roll(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
11861186
mp_raise_TypeError(MP_ERROR_TEXT("roll argument must be an ndarray"));
11871187
}
11881188
ndarray_obj_t *ndarray = MP_OBJ_TO_PTR(args[0].u_obj);
1189-
uint8_t *array = ndarray->array;
11901189
ndarray_obj_t *results = ndarray_new_dense_ndarray(ndarray->ndim, ndarray->shape, ndarray->dtype);
11911190

11921191
int32_t shift = mp_obj_get_int(args[1].u_obj);
1192+
1193+
if(shift == 0) {
1194+
ndarray_copy_array(ndarray, results, 0);
1195+
return MP_OBJ_FROM_PTR(results);
1196+
}
1197+
11931198
int32_t _shift = shift < 0 ? -shift : shift;
11941199

11951200
size_t counter;
1201+
uint8_t *array = ndarray->array;
11961202
uint8_t *rarray = (uint8_t *)results->array;
11971203

11981204
if(args[2].u_obj == mp_const_none) { // roll the flattened array

code/ulab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "user/user.h"
3434
#include "utils/utils.h"
3535

36-
#define ULAB_VERSION 6.5.3
36+
#define ULAB_VERSION 6.5.4
3737
#define xstr(s) str(s)
3838
#define str(s) #s
3939

docs/ulab-change-log.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat, 14 Sep 2024
2+
3+
version 6.5.4
4+
5+
fix roll, when shift is 0
6+
17
Wed, 6 Mar 2024
28

39
version 6.5.2

0 commit comments

Comments
 (0)