Port to CircuitPython

This commit is contained in:
Jeff Epler 2020-02-06 15:53:49 -06:00 committed by Jeff Epler
parent 4a0677fd14
commit 21b5a130c8
10 changed files with 31 additions and 6 deletions

14
code/compat.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef MICROPY_INCLUDED_ULAB_COMPAT_H
#define MICROPY_INCLUDED_ULAB_COMPAT_H
#pragma GCC diagnostic ignored "-Wshadow"
#define mp_obj_is_type(obj, type) MP_OBJ_IS_TYPE(obj, type)
#define mp_obj_is_int(obj) MP_OBJ_IS_INT(obj)
#define MP_ROM_NONE (MP_ROM_PTR(&mp_const_none_obj))
#define MP_ROM_FALSE (mp_const_false)
#define MP_ROM_TRUE (mp_const_true)
#endif // MICROPY_INCLUDED_ULAB_COMPAT_H

View file

@ -17,6 +17,7 @@
#include "py/binary.h" #include "py/binary.h"
#include "py/obj.h" #include "py/obj.h"
#include "py/objarray.h" #include "py/objarray.h"
#include "compat.h"
#include "ndarray.h" #include "ndarray.h"
#include "fft.h" #include "fft.h"

View file

@ -15,6 +15,7 @@
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/misc.h" #include "py/misc.h"
#include "compat.h"
#include "filter.h" #include "filter.h"
#if ULAB_FILTER_CONVOLVE #if ULAB_FILTER_CONVOLVE

View file

@ -15,6 +15,7 @@
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/misc.h" #include "py/misc.h"
#include "compat.h"
#include "linalg.h" #include "linalg.h"
#if ULAB_LINALG_TRANSPOSE #if ULAB_LINALG_TRANSPOSE

View file

@ -17,6 +17,7 @@
#include "py/binary.h" #include "py/binary.h"
#include "py/obj.h" #include "py/obj.h"
#include "py/objtuple.h" #include "py/objtuple.h"
#include "compat.h"
#include "ndarray.h" #include "ndarray.h"
// This function is copied verbatim from objarray.c // This function is copied verbatim from objarray.c
@ -165,11 +166,14 @@ STATIC uint8_t ndarray_init_helper(size_t n_args, const mp_obj_t *pos_args, mp_m
return dtype; return dtype;
} }
mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, n_kw, 1, 2, true); mp_arg_check_num(n_args, kw_args, 1, 2, true);
mp_map_t kw_args; size_t n_kw = 0;
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); if (kw_args != 0) {
uint8_t dtype = ndarray_init_helper(n_args, args, &kw_args); n_kw = kw_args->used;
}
mp_map_init_fixed_table(kw_args, n_kw, args + n_args);
uint8_t dtype = ndarray_init_helper(n_args, args, kw_args);
size_t len1, len2=0, i=0; size_t len1, len2=0, i=0;
mp_obj_t len_in = mp_obj_len_maybe(args[0]); mp_obj_t len_in = mp_obj_len_maybe(args[0]);

View file

@ -58,7 +58,7 @@ void ndarray_assign_elements(mp_obj_array_t *, mp_obj_t , uint8_t , size_t *);
ndarray_obj_t *create_new_ndarray(size_t , size_t , uint8_t ); ndarray_obj_t *create_new_ndarray(size_t , size_t , uint8_t );
mp_obj_t ndarray_copy(mp_obj_t ); mp_obj_t ndarray_copy(mp_obj_t );
mp_obj_t ndarray_make_new(const mp_obj_type_t *, size_t , size_t , const mp_obj_t *); mp_obj_t ndarray_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args);
mp_obj_t ndarray_subscr(mp_obj_t , mp_obj_t , mp_obj_t ); mp_obj_t ndarray_subscr(mp_obj_t , mp_obj_t , mp_obj_t );
mp_obj_t ndarray_getiter(mp_obj_t , mp_obj_iter_buf_t *); mp_obj_t ndarray_getiter(mp_obj_t , mp_obj_iter_buf_t *);
mp_obj_t ndarray_binary_op(mp_binary_op_t , mp_obj_t , mp_obj_t ); mp_obj_t ndarray_binary_op(mp_binary_op_t , mp_obj_t , mp_obj_t );

View file

@ -17,6 +17,7 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "py/builtin.h" #include "py/builtin.h"
#include "py/misc.h" #include "py/misc.h"
#include "compat.h"
#include "numerical.h" #include "numerical.h"
enum NUMERICAL_FUNCTION_TYPE { enum NUMERICAL_FUNCTION_TYPE {

View file

@ -12,6 +12,7 @@
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/objarray.h" #include "py/objarray.h"
#include "compat.h"
#include "ndarray.h" #include "ndarray.h"
#include "linalg.h" #include "linalg.h"
#include "poly.h" #include "poly.h"

View file

@ -19,6 +19,7 @@
#include "py/objarray.h" #include "py/objarray.h"
#include "ulab.h" #include "ulab.h"
#include "compat.h"
#include "ndarray.h" #include "ndarray.h"
#include "linalg.h" #include "linalg.h"
#include "vectorise.h" #include "vectorise.h"

View file

@ -16,6 +16,7 @@
#include "py/binary.h" #include "py/binary.h"
#include "py/obj.h" #include "py/obj.h"
#include "py/objarray.h" #include "py/objarray.h"
#include "compat.h"
#include "vectorise.h" #include "vectorise.h"
#ifndef MP_PI #ifndef MP_PI