Re: pyrex problems

"Marco Zanger" <[email protected]>
Newsgroups gmane.comp.python.pyrex,gmane.comp.python.cython.devel
Message-ID <[email protected]>
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 <[email protected]>:
>
> On Mon, Apr 21, 2008 at 3:27 PM, Marco Zanger <[email protected]>
> 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
> >  [email protected]
> >  http://lists.copyleft.no/mailman/listinfo/pyrex
> >
> >
>
>
>
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>

_______________________________________________
Pyrex mailing list
[email protected]
http://lists.copyleft.no/mailman/listinfo/pyrex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.