[Pyrex] pyrex problems

Marco Zanger marcozanger at gmail.com
Tue Apr 22 01:21:41 CEST 2008


Yep, i red that later. But what about the "no attribute" thing that pop-ups
when i try to call the methods? do u have any idea?

Thank u for the quick response,
Marco

2008/4/21, William Stein <wstein at gmail.com>:
>
> On Mon, Apr 21, 2008 at 3:27 PM, Marco Zanger <marcozanger at gmail.com>
> wrote:
> > Hi, I've been reading the WrappingC++ code with pyrex/Cython. But I'm
> still
> > unable to compile it; even the attached example.
> >
> > when I run  "pyrexc rectangle.pyx "
> > I get:
> >
> > .../rectangle.pyx:29:27: Syntax error in C variable declaration
> >
> > Which refers to
> >
> >     def __add__(Rectangle left, Rectangle right):
> >         cdef c_Rectangle c = left.thisptr.add(right.thisptr[0])
>
>
> I think Pyrex doesn't allow declaring and setting a variable, i.e.,
>
>   cdef int i = 10
>
> is not valid Pyrex.  You have to write:
>
>     cdef int i
>     i = 10
>
> In contrast, Cython allows
>
>     cdef int i = 10
>
> since Robert Bradshaw was working on Cython one day and thought that
> would be a nice feature to have...
>
>   -- William
>
>
> >         cdef Rectangle sum = Rectangle(c.x0, c.y0, c.x1, c.y1)
> >          return sum
> >
> > And in my own code i get the following
> >
> > GOptimization.pyx:91:32: Object of type 'cGCoptimization' has no
> attribute
> > 'expansionIter'
> >
> > And the code which refers is
> >
> > cdef extern from "GCoptimization.h":
> >
> >    ctypedef int PixelType
> >
> >      ctypedef struct cGCoptimization "GCoptimization":
> >          EnergyType expansionIter "expansion"(int max_num_iterations)
> >
> >      cGCoptimization *newGCoptimization "new GCoptimization" (PixelType
> > num_pixels,int num_labels,int dataSetup, int smoothSetup)
> >
> >     void delGCOptimization "delete" (cGCoptimization *optimization)
> >
> > cdef class GCoptimization:
> >      cdef cGCoptimization *optimization
> >     def __new__(self, num_pixels, num_labels, dataSetup, smoothSetup):
> >          self.optimization = newGCoptimization(num_pixels, num_labels,
> > dataSetup, smoothSetup)
> >     def __dealloc__(self):
> >          delGCOptimization(self.optimization)
> >     def expansionIter(self,max_num_iterations):
> >          return self.optimization.expansionIter(max_num_iterations)
> >
> > If u have any idea to give I would appreciate it very much, I'm kind of
> lost
> > in here.
> >
> > Thank you, again,
> > Warmest Regards,
> > Marco
>
> > _______________________________________________
> >  Pyrex mailing list
> >  Pyrex at lists.copyleft.no
> >  http://lists.copyleft.no/mailman/listinfo/pyrex
> >
> >
>
>
>
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20080422/3fdfdbe2/attachment-0001.html 


More information about the Pyrex mailing list