Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll fix #687

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading