Skip to content

Commit

Permalink
Roll fix (#687)
Browse files Browse the repository at this point in the history
* fix roll, when shift is 0
  • Loading branch information
v923z authored Sep 14, 2024
1 parent 1d3ddd8 commit 45f23eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion code/numpy/numerical.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/ulab.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions docs/ulab-change-log.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 45f23eb

Please sign in to comment.