Commit 6d343f58 authored by Yury V. Zaytsev's avatar Yury V. Zaytsev

Fix broken code samples (indent, spaces, failing doctest)

parent 6436c7d2
......@@ -37,14 +37,14 @@ function on floating point numbers::
cdef class Function:
cpdef double evaluate(self, double x) except *:
return 0
return 0
Like before, cpdef makes two versions of the method available; one
fast for use from Cython and one slower for use from Python. Then::
cdef class SinOfSquareFunction(Function):
cpdef double evaluate(self, double x) except *:
return sin(x**2)
return sin(x**2)
Using this, we can now change our integration example::
......@@ -134,8 +134,8 @@ Attributes in cdef classes behave differently from attributes in regular classes
cdef public double freq
# Available in Python-space:
property period:
def __get__(self):
return 1.0 / self. freq
def __set__(self, value):
self. freq = 1.0 / value
def __get__(self):
return 1.0 / self.freq
def __set__(self, value):
self.freq = 1.0 / value
<...>
......@@ -440,7 +440,7 @@ The following listing shows the complete implementation that uses
raise IndexError("Queue is empty")
return value
cdef int pop(self) except? -1:
cpdef int pop(self) except? -1:
if cqueue.queue_is_empty(self._c_queue):
raise IndexError("Queue is empty")
return <int>cqueue.queue_pop_head(self._c_queue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment