Am 18. Oktober 2017 15:14:46 MESZ schrieb Zahra Sheikh:
>Well I ended up defining a function as follows:
>cdef extern from "math.h":
> cdef double INFINITY
> cdef double NAN
>cdef bint _isinf(double x):
> return (x == INFINITY)
If positive infinity is enough, then that's probably ok.
>I have another question: I am trying to pass a string as an argument to
>a function in my cython code
>
>*ctypedef unsigned char char_typedef sample(int n, char_type[:]
>interval_method ='doubling'): cdef int doubling_used=1 if
>(interval_method!='doubling'): doubling_used=0but it raises the
>following error message:char_type[:] interval_method ='doubling'):
>File
>"stringsource", line 644, in View.MemoryView.memoryview_cwrapper File
>"stringsource", line 345, in
>View.MemoryView.memoryview.__cinit__BufferError: Object is not
>writable.*
>
>Is there any other approaches to pass a character or string as an
>argument to a function in cython?
Sure. Just pass it, don't specify a type.
More details are here:
http://docs.cython.org/en/latest/src/tutorial/strings.html
Stefan