Merge commit 'refs/pull/431/head' of https://github.com/v923z/micropython-ulab into build-all-dimensions
This commit is contained in:
commit
8b3b4d1829
10 changed files with 33 additions and 8 deletions
|
|
@ -396,11 +396,13 @@ static void ndarray_print_row(const mp_print_t *print, ndarray_obj_t * ndarray,
|
|||
mp_print_str(print, "]");
|
||||
}
|
||||
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
static void ndarray_print_bracket(const mp_print_t *print, const size_t condition, const size_t shape, const char *string) {
|
||||
if(condition < shape) {
|
||||
mp_print_str(print, string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ndarray_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
|
|
@ -411,9 +413,13 @@ void ndarray_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
|
|||
mp_print_str(print, "[]");
|
||||
if(self->ndim > 1) {
|
||||
mp_print_str(print, ", shape=(");
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
for(uint8_t ndim = self->ndim; ndim > 1; ndim--) {
|
||||
mp_printf(MP_PYTHON_PRINTER, "%d,", self->shape[ULAB_MAX_DIMS - ndim]);
|
||||
}
|
||||
#else
|
||||
mp_printf(MP_PYTHON_PRINTER, "%d,", self->shape[0]);
|
||||
#endif
|
||||
mp_printf(MP_PYTHON_PRINTER, "%d)", self->shape[ULAB_MAX_DIMS - 1]);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -89,11 +89,13 @@ void ndarray_properties_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
|||
} else {
|
||||
if(dest[1]) {
|
||||
switch(attr) {
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
#if NDARRAY_HAS_RESHAPE
|
||||
case MP_QSTR_shape:
|
||||
ndarray_reshape_core(self_in, dest[1], 1);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -579,6 +579,7 @@ static mp_obj_t numerical_sort_helper(mp_obj_t oin, mp_obj_t axis, uint8_t inpla
|
|||
int8_t ax = 0;
|
||||
if(axis == mp_const_none) {
|
||||
// flatten the array
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
for(uint8_t i=0; i < ULAB_MAX_DIMS - 1; i++) {
|
||||
ndarray->shape[i] = 0;
|
||||
ndarray->strides[i] = 0;
|
||||
|
|
@ -586,6 +587,7 @@ static mp_obj_t numerical_sort_helper(mp_obj_t oin, mp_obj_t axis, uint8_t inpla
|
|||
ndarray->shape[ULAB_MAX_DIMS - 1] = ndarray->len;
|
||||
ndarray->strides[ULAB_MAX_DIMS - 1] = ndarray->itemsize;
|
||||
ndarray->ndim = 1;
|
||||
#endif
|
||||
} else {
|
||||
ax = mp_obj_get_int(axis);
|
||||
if(ax < 0) ax += ndarray->ndim;
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@
|
|||
} while(0)
|
||||
|
||||
#define RUN_MEAN_STD(type, array, rarray, ss, div, isStd) do {\
|
||||
RUN_MEAN_STD1(type, (array), (results), (rarray), (ss), (div), (isStd));\
|
||||
RUN_MEAN_STD1(type, (array), (rarray), (ss), (div), (isStd));\
|
||||
} while(0)
|
||||
|
||||
#define RUN_ARGMIN(ndarray, type, array, results, rarray, shape, strides, index, op) do {\
|
||||
|
|
|
|||
|
|
@ -146,8 +146,10 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_concatenate), (mp_obj_t)&create_concatenate_obj },
|
||||
#endif
|
||||
#if ULAB_NUMPY_HAS_DIAG
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
{ MP_ROM_QSTR(MP_QSTR_diag), (mp_obj_t)&create_diag_obj },
|
||||
#endif
|
||||
#endif
|
||||
#if ULAB_NUMPY_HAS_EMPTY
|
||||
{ MP_ROM_QSTR(MP_QSTR_empty), (mp_obj_t)&create_zeros_obj },
|
||||
#endif
|
||||
|
|
@ -229,11 +231,15 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = {
|
|||
{ MP_OBJ_NEW_QSTR(MP_QSTR_diff), (mp_obj_t)&numerical_diff_obj },
|
||||
#endif
|
||||
#if ULAB_NUMPY_HAS_DOT
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_dot), (mp_obj_t)&transform_dot_obj },
|
||||
#endif
|
||||
#endif
|
||||
#if ULAB_NUMPY_HAS_TRACE
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
{ MP_ROM_QSTR(MP_QSTR_trace), (mp_obj_t)&stats_trace_obj },
|
||||
#endif
|
||||
#endif
|
||||
#if ULAB_NUMPY_HAS_FLIP
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_flip), (mp_obj_t)&numerical_flip_obj },
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "../ulab_tools.h"
|
||||
#include "transform.h"
|
||||
|
||||
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
#if ULAB_NUMPY_HAS_DOT
|
||||
//| def dot(m1: ulab.numpy.ndarray, m2: ulab.numpy.ndarray) -> Union[ulab.numpy.ndarray, _float]:
|
||||
//| """
|
||||
|
|
@ -87,3 +87,4 @@ mp_obj_t transform_dot(mp_obj_t _m1, mp_obj_t _m2) {
|
|||
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(transform_dot_obj, transform_dot);
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#include "user/user.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define ULAB_VERSION 3.3.2
|
||||
#define ULAB_VERSION 3.3.3
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
#define ULAB_VERSION_STRING xstr(ULAB_VERSION) xstr(-) xstr(ULAB_MAX_DIMS) xstr(D)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@
|
|||
// By setting this constant to 1, iteration over array dimensions will be implemented
|
||||
// as a function (ndarray_rewind_array), instead of writing out the loops in macros
|
||||
// This reduces firmware size at the expense of speed
|
||||
#ifndef ULAB_HAS_FUNCTION_ITERATOR
|
||||
#define ULAB_HAS_FUNCTION_ITERATOR (0)
|
||||
#endif
|
||||
|
||||
// If NDARRAY_IS_ITERABLE is 1, the ndarray object defines its own iterator function
|
||||
// This option saves approx. 250 bytes of flash space
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ mp_obj_t create_concatenate(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
|
|||
MP_DEFINE_CONST_FUN_OBJ_KW(create_concatenate_obj, 1, create_concatenate);
|
||||
#endif
|
||||
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
#if ULAB_NUMPY_HAS_DIAG
|
||||
mp_obj_t create_diag(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
|
@ -314,7 +315,6 @@ mp_obj_t create_diag(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
|||
MP_DEFINE_CONST_FUN_OBJ_KW(create_diag_obj, 1, create_diag);
|
||||
#endif /* ULAB_NUMPY_HAS_DIAG */
|
||||
|
||||
#if ULAB_MAX_DIMS > 1
|
||||
#if ULAB_NUMPY_HAS_EYE
|
||||
mp_obj_t create_eye(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
Fri, 23 Jul 2021
|
||||
|
||||
version 3.3.3
|
||||
|
||||
fix compilation for one dimension
|
||||
|
||||
Thu, 22 Jul 2021
|
||||
|
||||
version 3.3.2
|
||||
|
|
|
|||
Loading…
Reference in a new issue