Merge pull request #488 from v923z/bool-invert
fix ndarray_copy_view for Boolean dtypes
This commit is contained in:
commit
15918fdb89
3 changed files with 9 additions and 10 deletions
|
|
@ -387,14 +387,6 @@ MP_DEFINE_CONST_FUN_OBJ_0(ndarray_get_printoptions_obj, ndarray_get_printoptions
|
||||||
mp_obj_t ndarray_get_item(ndarray_obj_t *ndarray, void *array) {
|
mp_obj_t ndarray_get_item(ndarray_obj_t *ndarray, void *array) {
|
||||||
// returns a proper micropython object from an array
|
// returns a proper micropython object from an array
|
||||||
if(!ndarray->boolean) {
|
if(!ndarray->boolean) {
|
||||||
#if ULAB_SUPPORTS_COMPLEX
|
|
||||||
if(ndarray->dtype == NDARRAY_COMPLEX) {
|
|
||||||
mp_float_t *c = (mp_float_t *)array;
|
|
||||||
mp_float_t real = *c++;
|
|
||||||
mp_float_t imag = *c;
|
|
||||||
return mp_obj_new_complex(real, imag);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return mp_binary_get_val_array(ndarray->dtype, array, 0);
|
return mp_binary_get_val_array(ndarray->dtype, array, 0);
|
||||||
} else {
|
} else {
|
||||||
if(*(uint8_t *)array) {
|
if(*(uint8_t *)array) {
|
||||||
|
|
@ -735,8 +727,9 @@ ndarray_obj_t *ndarray_copy_view(ndarray_obj_t *source) {
|
||||||
|
|
||||||
uint8_t dtype = source->dtype;
|
uint8_t dtype = source->dtype;
|
||||||
if(source->boolean) {
|
if(source->boolean) {
|
||||||
dtype = NDARRAY_BOOLEAN;
|
dtype = NDARRAY_BOOL;
|
||||||
}
|
}
|
||||||
|
// printf("%d\n", dtype);
|
||||||
ndarray_obj_t *ndarray = ndarray_new_ndarray(source->ndim, source->shape, strides, dtype);
|
ndarray_obj_t *ndarray = ndarray_new_ndarray(source->ndim, source->shape, strides, dtype);
|
||||||
ndarray_copy_array(source, ndarray, 0);
|
ndarray_copy_array(source, ndarray, 0);
|
||||||
return ndarray;
|
return ndarray;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include "user/user.h"
|
#include "user/user.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
#define ULAB_VERSION 4.2.0
|
#define ULAB_VERSION 4.2.1
|
||||||
#define xstr(s) str(s)
|
#define xstr(s) str(s)
|
||||||
#define str(s) #s
|
#define str(s) #s
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
Tue, 18 Jan 2022
|
||||||
|
|
||||||
|
version 4.2.1
|
||||||
|
|
||||||
|
fix ndarray_copy_view for Boolean dtypes
|
||||||
|
|
||||||
Fri, 14 Jan 2022
|
Fri, 14 Jan 2022
|
||||||
|
|
||||||
version 4.2.0
|
version 4.2.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue