How do I fix this? cython doesn't seem to like my use of functions as
parameters.
/home/nbecker/raysat/mod/test1.pyx:27:110: Cannot assign type 'numpy.int64_t
(numpy.int64_t, int, numpy.int64_t, int __pyx_skip_dispatch)' to
'test1.rnd_policy_t'
import numpy as np
cimport numpy as np
from numpy cimport int64_t
cpdef int64_t rnd (int64_t x, int frac_bits, int64_t _max):
"A rounding policy"
cdef int64_t x1
x1 = x >> (frac_bits-1)
if (x1 == _max):
return x1 >> 1
else:
return (x1+1) >> 1
ctypedef int64_t (*rnd_policy_t)(int64_t, int, int64_t)
cpdef int64_t clip (int64_t x, int64_t _min, int64_t _max):
"overflow policy that clips"
if x > _max:
return _max
elif x < _min:
return _min
else:
return x
ctypedef int64_t (*overflow_policy_t)(int64_t, int64_t, int64_t)
cdef class fixed_pt (object):
def __init__ (self, int int_bits, int frac_bits, int64_t val, bool
scale=True, rnd_policy_t rnd_policy=rnd, overflow_policy_t
overflow_policy=clip):
pass
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev