* fix roll, when shift is 0
This commit is contained in:
Zoltán Vörös 2024-09-14 11:38:04 +02:00 committed by GitHub
parent 1d3ddd8f52
commit 45f23ebc82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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