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