On Thu, May 14, 2009 at 4:45 AM, John Cremona <john.crem...@gmail.com> wrote: > > Your comment about the sum function suggests to me that something > similar might be behind the weird thing I reported yesterday.
Yeah, we ought to suggest to the pari people to rename such generic function. Even with C++ code in Sage having a class called Rational in at least three different C++ based components of Sage causes fun to no end in case the linker screws up. > If you take a fresh clone of 3.4.2, and in the file > sage/rings/rational.pyx add this function: > > def dummy(self): > return sum([a for a in self.list()],0) > > say at line 391 (so inside the cdef class Rational()), then "sage -br" > complains like this: > > Building modified file sage/rings/rational.pyx. > python2.5 `which cython` --embed-positions --incref-local-binop > -I/home/jec/sage-3.4.2/devel/sage-tests -o sage/rings/rational.c > sage/rings/rational.pyx > > Error converting Pyrex file to C: > ------------------------------------------------------------ > ... > [5/3] > """ > return [ self ] > > def dummy(self): > return sum([a for a in self.list()],0) > ^ > ------------------------------------------------------------ > > /home/jec/sage-3.4.2/devel/sage-tests/sage/rings/rational.pyx:392:18: > Call with wrong number of arguments (expected 3, got 2) > Error running command, failed with status 256. > sage: There was an error installing modified sage library code. > > Note that it (wrongly) says that the sum function wants 3 arguments. > If you try adding a third arguement, say by changing the code to > > def dummy(self): > return sum([a for a in self.list()],0,0) > > then the error message changes to > /home/jec/sage-3.4.2/devel/sage-tests/sage/rings/rational.pyx:392:18: > Cannot convert 'sage.rings.rational.GEN' to Python object > > and the only place I know where things are called GEN is in pari, > where there is a sum() function which takes 3 arguments (as declared > in sage/libs/pari/decl.pxi: GEN sum(GEN v, long a, long b) > > So my diagnosis is that when rational.pyx is recompiled, it is picking > up the wrong sum(). > > Sorry, I am not qualified to provide a cure! It is quite surpriding > if the sum() function has never before been used in a .pyx file! > John Well, I assume most people work around it. In case you want to have some fun: Pull in GSL as well as the pari definitions in the same file. The preprocessor will start complaining rather loudly. Cheers, Michael --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---