diff --git a/code/numpy/compare.c b/code/numpy/compare.c index 5845a9d..f72fde8 100644 --- a/code/numpy/compare.c +++ b/code/numpy/compare.c @@ -23,6 +23,23 @@ #include "carray/carray_tools.h" #include "compare.h" +#ifdef ULAB_NUMPY_HAS_BINCOUNT +mp_obj_t compare_bincount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + static const mp_arg_t allowed_args[] = { + { MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE} } , + { MP_QSTR_weights, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } }, + { MP_QSTR_minlength, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + return mp_const_none; +} + +MP_DEFINE_CONST_FUN_OBJ_KW(compare_bincount_obj, 1, compare_bincount); +#endif /* ULAB_NUMPY_HAS_BINCOUNT */ + static mp_obj_t compare_function(mp_obj_t x1, mp_obj_t x2, uint8_t op) { ndarray_obj_t *lhs = ndarray_from_mp_obj(x1, 0); ndarray_obj_t *rhs = ndarray_from_mp_obj(x2, 0); diff --git a/code/numpy/compare.h b/code/numpy/compare.h index de3d7e6..668903e 100644 --- a/code/numpy/compare.h +++ b/code/numpy/compare.h @@ -23,6 +23,7 @@ enum COMPARE_FUNCTION_TYPE { COMPARE_CLIP, }; +MP_DECLARE_CONST_FUN_OBJ_KW(compare_bincount_obj); MP_DECLARE_CONST_FUN_OBJ_3(compare_clip_obj); MP_DECLARE_CONST_FUN_OBJ_2(compare_equal_obj); MP_DECLARE_CONST_FUN_OBJ_2(compare_isfinite_obj); diff --git a/code/numpy/numpy.c b/code/numpy/numpy.c index eafd772..765f5d1 100644 --- a/code/numpy/numpy.c +++ b/code/numpy/numpy.c @@ -169,6 +169,9 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = { #if ULAB_NUMPY_HAS_ZEROS { MP_ROM_QSTR(MP_QSTR_zeros), MP_ROM_PTR(&create_zeros_obj) }, #endif + #if ULAB_NUMPY_HAS_BINCOUNT + { MP_ROM_QSTR(MP_QSTR_bincount), MP_ROM_PTR(&compare_bincount_obj) }, + #endif #if ULAB_NUMPY_HAS_CLIP { MP_ROM_QSTR(MP_QSTR_clip), MP_ROM_PTR(&compare_clip_obj) }, #endif diff --git a/code/ulab.c b/code/ulab.c index c1f32c0..8a0b50c 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.9.0 +#define ULAB_VERSION 6.10.0 #define xstr(s) str(s) #define str(s) #s diff --git a/code/ulab.h b/code/ulab.h index 597cdef..ca23443 100644 --- a/code/ulab.h +++ b/code/ulab.h @@ -374,6 +374,10 @@ #endif // functions that compare arrays +#ifndef ULAB_NUMPY_HAS_BINCOUNT +#define ULAB_NUMPY_HAS_BINCOUNT (1) +#endif + #ifndef ULAB_NUMPY_HAS_CLIP #define ULAB_NUMPY_HAS_CLIP (1) #endif @@ -413,7 +417,7 @@ // the integrate module; functions of the integrate module still have // to be defined separately #ifndef ULAB_SCIPY_HAS_INTEGRATE_MODULE -#define ULAB_SCIPY_HAS_INTEGRATE_MODULE (1) +#define ULAB_SCIPY_HAS_INTEGRATE_MODULE (1) #endif #ifndef ULAB_INTEGRATE_HAS_TANHSINH