Skip to content

Commit 13974df

Browse files
committed
working skeletoon of bincount
1 parent 068da5f commit 13974df

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

code/numpy/compare.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@
2323
#include "carray/carray_tools.h"
2424
#include "compare.h"
2525

26+
#ifdef ULAB_NUMPY_HAS_BINCOUNT
27+
mp_obj_t compare_bincount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
28+
static const mp_arg_t allowed_args[] = {
29+
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE} } ,
30+
{ MP_QSTR_weights, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
31+
{ MP_QSTR_minlength, MP_ARG_OBJ, { .u_rom_obj = MP_ROM_NONE } },
32+
};
33+
34+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
35+
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
36+
37+
return mp_const_none;
38+
}
39+
40+
MP_DEFINE_CONST_FUN_OBJ_KW(compare_bincount_obj, 1, compare_bincount);
41+
#endif /* ULAB_NUMPY_HAS_BINCOUNT */
42+
2643
static mp_obj_t compare_function(mp_obj_t x1, mp_obj_t x2, uint8_t op) {
2744
ndarray_obj_t *lhs = ndarray_from_mp_obj(x1, 0);
2845
ndarray_obj_t *rhs = ndarray_from_mp_obj(x2, 0);

code/numpy/compare.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum COMPARE_FUNCTION_TYPE {
2323
COMPARE_CLIP,
2424
};
2525

26+
MP_DECLARE_CONST_FUN_OBJ_KW(compare_bincount_obj);
2627
MP_DECLARE_CONST_FUN_OBJ_3(compare_clip_obj);
2728
MP_DECLARE_CONST_FUN_OBJ_2(compare_equal_obj);
2829
MP_DECLARE_CONST_FUN_OBJ_2(compare_isfinite_obj);

code/numpy/numpy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ static const mp_rom_map_elem_t ulab_numpy_globals_table[] = {
169169
#if ULAB_NUMPY_HAS_ZEROS
170170
{ MP_ROM_QSTR(MP_QSTR_zeros), MP_ROM_PTR(&create_zeros_obj) },
171171
#endif
172+
#if ULAB_NUMPY_HAS_BINCOUNT
173+
{ MP_ROM_QSTR(MP_QSTR_bincount), MP_ROM_PTR(&compare_bincount_obj) },
174+
#endif
172175
#if ULAB_NUMPY_HAS_CLIP
173176
{ MP_ROM_QSTR(MP_QSTR_clip), MP_ROM_PTR(&compare_clip_obj) },
174177
#endif

code/ulab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "user/user.h"
3434
#include "utils/utils.h"
3535

36-
#define ULAB_VERSION 6.9.0
36+
#define ULAB_VERSION 6.10.0
3737
#define xstr(s) str(s)
3838
#define str(s) #s
3939

code/ulab.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@
374374
#endif
375375

376376
// functions that compare arrays
377+
#ifndef ULAB_NUMPY_HAS_BINCOUNT
378+
#define ULAB_NUMPY_HAS_BINCOUNT (1)
379+
#endif
380+
377381
#ifndef ULAB_NUMPY_HAS_CLIP
378382
#define ULAB_NUMPY_HAS_CLIP (1)
379383
#endif
@@ -413,7 +417,7 @@
413417
// the integrate module; functions of the integrate module still have
414418
// to be defined separately
415419
#ifndef ULAB_SCIPY_HAS_INTEGRATE_MODULE
416-
#define ULAB_SCIPY_HAS_INTEGRATE_MODULE (1)
420+
#define ULAB_SCIPY_HAS_INTEGRATE_MODULE (1)
417421
#endif
418422

419423
#ifndef ULAB_INTEGRATE_HAS_TANHSINH

0 commit comments

Comments
 (0)