From ac2e9954edc185ec212e437e73e4b5e4290de35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20V=C3=B6r=C3=B6s?= Date: Sun, 7 May 2023 12:09:02 +0200 Subject: [PATCH] ndarray_from_mp_obj correctly treats Booleans (#613) --- code/ndarray.c | 6 ++++++ code/ulab.c | 2 +- docs/ulab-change-log.md | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/code/ndarray.c b/code/ndarray.c index f51d1bd0..4b340b23 100644 --- a/code/ndarray.c +++ b/code/ndarray.c @@ -1730,6 +1730,12 @@ ndarray_obj_t *ndarray_from_mp_obj(mp_obj_t obj, uint8_t other_type) { ndarray = ndarray_new_linear_array(1, NDARRAY_FLOAT); mp_float_t *array = (mp_float_t *)ndarray->array; array[0] = mp_obj_get_float(obj); + } else if(mp_obj_is_bool(obj)) { + ndarray = ndarray_new_linear_array(1, NDARRAY_BOOLEAN); + uint8_t *array = (uint8_t *)ndarray->array; + if(obj == mp_const_true) { + *array = 1; + } } else if(mp_obj_is_type(obj, &ulab_ndarray_type)){ return MP_OBJ_TO_PTR(obj); } diff --git a/code/ulab.c b/code/ulab.c index a7842569..a389831a 100644 --- a/code/ulab.c +++ b/code/ulab.c @@ -33,7 +33,7 @@ #include "user/user.h" #include "utils/utils.h" -#define ULAB_VERSION 6.0.11 +#define ULAB_VERSION 6.0.12 #define xstr(s) str(s) #define str(s) #s diff --git a/docs/ulab-change-log.md b/docs/ulab-change-log.md index 910055ff..f4aba8b6 100644 --- a/docs/ulab-change-log.md +++ b/docs/ulab-change-log.md @@ -1,3 +1,9 @@ +Sun, 7 May 2023 + +version 6.0.12 + + ndarray_from_mp_obj correctly treats Boolean arguments + Sat, 6 May 2023 version 6.0.11