1 # copyright 2016 Apache 2 sddekit authors
3 from sddekit_h cimport
*
6 ctypedef struct hfill_py
:
10 cdef sd_stat hfill_py_apply
(sd_hfill
*hfill
, uint32_t n
, double
* t
, uint32_t
*i
, double
* buf
):
11 cdef hfill_py
*hp
= <hfill_py
*> hfill
.ptr
12 cdef np
.ndarray
[np
.float64_t
, ndim
=1] np_buf
13 t_
= np_of_ptr
(n
, t
, np
.NPY_DOUBLE
, 0)
14 i_
= np_of_ptr
(n
, t
, np
.NPY_UINT64
, 0)
16 np_buf
= (<object> hp
.fn
)(t_
, i_
).astype
(np
.float64
)
17 except Exception as exc
:
24 cdef void hfill_py_free
(sd_hfill
*h
):
27 cdef sd_hfill
* hfill_py_new
(object fn
):
28 cdef hfill_py
*h
= <hfill_py
*> malloc
(sizeof(hfill_py
))
29 if not hasattr(fn
, '__call__'):
30 raise TypeError('arg fn must be callable')
32 raise Exception('alloc hfill_py failed.')
35 h
.hf
.apply = &hfill_py_apply
36 h
.hf
.free
= &hfill_py_free