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, "]");
|
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) {
|
static void ndarray_print_bracket(const mp_print_t *print, const size_t condition, const size_t shape, const char *string) {
|
||||||
if(condition < shape) {
|
if(condition < shape) {
|
||||||
mp_print_str(print, string);
|
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 ndarray_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||||
(void)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, "[]");
|
mp_print_str(print, "[]");
|
||||||
if(self->ndim > 1) {
|
if(self->ndim > 1) {
|
||||||
mp_print_str(print, ", shape=(");
|
mp_print_str(print, ", shape=(");
|
||||||
|
#if ULAB_MAX_DIMS > 1
|
||||||
for(uint8_t ndim = self->ndim; ndim > 1; ndim--) {
|
for(uint8_t ndim = self->ndim; ndim > 1; ndim--) {
|
||||||
mp_printf(MP_PYTHON_PRINTER, "%d,", self->shape[ULAB_MAX_DIMS - 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]);
|
mp_printf(MP_PYTHON_PRINTER, "%d)", self->shape[ULAB_MAX_DIMS - 1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -89,11 +89,13 @@ void ndarray_properties_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||||
} else {
|
} else {
|
||||||
if(dest[1]) {
|
if(dest[1]) {
|
||||||
switch(attr) {
|
switch(attr) {
|
||||||
|
#if ULAB_MAX_DIMS > 1
|
||||||
#if NDARRAY_HAS_RESHAPE
|
#if NDARRAY_HAS_RESHAPE
|
||||||
case MP_QSTR_shape:
|
case MP_QSTR_shape:
|
||||||
ndarray_reshape_core(self_in, dest[1], 1);
|
ndarray_reshape_core(self_in, dest[1], 1);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
break;
|
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;
|
int8_t ax = 0;
|
||||||
if(axis == mp_const_none) {
|
if(axis == mp_const_none) {
|
||||||
// flatten the array
|
// flatten the array
|
||||||
|
#if ULAB_MAX_DIMS > 1
|
||||||
for(uint8_t i=0; i < ULAB_MAX_DIMS - 1; i++) {
|
for(uint8_t i=0; i < ULAB_MAX_DIMS - 1; i++) {
|
||||||
ndarray->shape[i] = 0;
|
ndarray->shape[i] = 0;
|
||||||
ndarray->strides[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->shape[ULAB_MAX_DIMS - 1] = ndarray->len;
|
||||||
ndarray->strides[ULAB_MAX_DIMS - 1] = ndarray->itemsize;
|
ndarray->strides[ULAB_MAX_DIMS - 1] = ndarray->itemsize;
|
||||||
ndarray->ndim = 1;
|
ndarray->ndim = 1;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ax = mp_obj_get_int(axis);
|
ax = mp_obj_get_int(axis);
|
||||||
if(ax < 0) ax += ndarray->ndim;
|
if(ax < 0) ax += ndarray->ndim;
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define RUN_MEAN_STD(type, array, rarray, ss, div, isStd) do {\
|
#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)
|
} while(0)
|
||||||
|
|
||||||
#define RUN_ARGMIN(ndarray, type, array, results, rarray, shape, strides, index, op) do {\
|
#define RUN_ARGMIN(ndarray, type, array, results, rarray, shape, strides, index, op) do {\
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,9 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_concatenate), (mp_obj_t)&create_concatenate_obj },
|
{ MP_ROM_QSTR(MP_QSTR_concatenate), (mp_obj_t)&create_concatenate_obj },
|
||||||
#endif
|
#endif
|
||||||
#if ULAB_NUMPY_HAS_DIAG
|
#if ULAB_NUMPY_HAS_DIAG
|
||||||
{ MP_ROM_QSTR(MP_QSTR_diag), (mp_obj_t)&create_diag_obj },
|
#if ULAB_MAX_DIMS > 1
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_diag), (mp_obj_t)&create_diag_obj },
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if ULAB_NUMPY_HAS_EMPTY
|
#if ULAB_NUMPY_HAS_EMPTY
|
||||||
{ MP_ROM_QSTR(MP_QSTR_empty), (mp_obj_t)&create_zeros_obj },
|
{ MP_ROM_QSTR(MP_QSTR_empty), (mp_obj_t)&create_zeros_obj },
|
||||||
|
|
@ -229,10 +231,14 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = {
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_diff), (mp_obj_t)&numerical_diff_obj },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_diff), (mp_obj_t)&numerical_diff_obj },
|
||||||
#endif
|
#endif
|
||||||
#if ULAB_NUMPY_HAS_DOT
|
#if ULAB_NUMPY_HAS_DOT
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_dot), (mp_obj_t)&transform_dot_obj },
|
#if ULAB_MAX_DIMS > 1
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_dot), (mp_obj_t)&transform_dot_obj },
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if ULAB_NUMPY_HAS_TRACE
|
#if ULAB_NUMPY_HAS_TRACE
|
||||||
{ MP_ROM_QSTR(MP_QSTR_trace), (mp_obj_t)&stats_trace_obj },
|
#if ULAB_MAX_DIMS > 1
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_trace), (mp_obj_t)&stats_trace_obj },
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if ULAB_NUMPY_HAS_FLIP
|
#if ULAB_NUMPY_HAS_FLIP
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_flip), (mp_obj_t)&numerical_flip_obj },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_flip), (mp_obj_t)&numerical_flip_obj },
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include "../ulab_tools.h"
|
#include "../ulab_tools.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
|
#if ULAB_MAX_DIMS > 1
|
||||||
#if ULAB_NUMPY_HAS_DOT
|
#if ULAB_NUMPY_HAS_DOT
|
||||||
//| def dot(m1: ulab.numpy.ndarray, m2: ulab.numpy.ndarray) -> Union[ulab.numpy.ndarray, _float]:
|
//| 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);
|
MP_DEFINE_CONST_FUN_OBJ_2(transform_dot_obj, transform_dot);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include "user/user.h"
|
#include "user/user.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
#define ULAB_VERSION 3.3.2
|
#define ULAB_VERSION 3.3.3
|
||||||
#define xstr(s) str(s)
|
#define xstr(s) str(s)
|
||||||
#define str(s) #s
|
#define str(s) #s
|
||||||
#define ULAB_VERSION_STRING xstr(ULAB_VERSION) xstr(-) xstr(ULAB_MAX_DIMS) xstr(D)
|
#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
|
// 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
|
// as a function (ndarray_rewind_array), instead of writing out the loops in macros
|
||||||
// This reduces firmware size at the expense of speed
|
// This reduces firmware size at the expense of speed
|
||||||
|
#ifndef ULAB_HAS_FUNCTION_ITERATOR
|
||||||
#define ULAB_HAS_FUNCTION_ITERATOR (0)
|
#define ULAB_HAS_FUNCTION_ITERATOR (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// If NDARRAY_IS_ITERABLE is 1, the ndarray object defines its own iterator function
|
// If NDARRAY_IS_ITERABLE is 1, the ndarray object defines its own iterator function
|
||||||
// This option saves approx. 250 bytes of flash space
|
// 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);
|
MP_DEFINE_CONST_FUN_OBJ_KW(create_concatenate_obj, 1, create_concatenate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ULAB_MAX_DIMS > 1
|
||||||
#if ULAB_NUMPY_HAS_DIAG
|
#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) {
|
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[] = {
|
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);
|
MP_DEFINE_CONST_FUN_OBJ_KW(create_diag_obj, 1, create_diag);
|
||||||
#endif /* ULAB_NUMPY_HAS_DIAG */
|
#endif /* ULAB_NUMPY_HAS_DIAG */
|
||||||
|
|
||||||
#if ULAB_MAX_DIMS > 1
|
|
||||||
#if ULAB_NUMPY_HAS_EYE
|
#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) {
|
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[] = {
|
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
|
Thu, 22 Jul 2021
|
||||||
|
|
||||||
version 3.3.2
|
version 3.3.2
|
||||||
|
|
@ -21,7 +27,7 @@ Tue, 13 Jul 2021
|
||||||
version 3.2.0
|
version 3.2.0
|
||||||
|
|
||||||
add flatiter/flat to ndarray methods
|
add flatiter/flat to ndarray methods
|
||||||
|
|
||||||
Tue, 22 Jun 2021
|
Tue, 22 Jun 2021
|
||||||
|
|
||||||
version 3.1.1
|
version 3.1.1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue