On Thu, Jul 19, 2012 at 10:50 AM, Sébastien Labbé <sla...@gmail.com> wrote:
> Hi sage-devel,
>
> Using sage-5.0, it appears that (-1 % 2) gets different values if it is in a
> python file (=1), in a attached cython file (=1) or in a cython file in the
> sage tree (= -1) !
>
> Add the following three lines to sage/combinat/partition.py :
>
> +aaa = -1
> +tmp = aaa % 2
> +print "In sage/combinat/partition.py : -1 % 2 is ", tmp
>
> Add the following three lines to sage/combinat/partitions.pyx :
>
> +cdef int aaa = -1
> +tmp = aaa % 2
> +print "In sage/combinat/partitions.pyx : -1 % 2 is ", tmp
>
> Then :
>
> ----------------------------------------------------------------------
> | Sage Version 5.0, Release Date: 2012-05-14                         |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> In sage/combinat/partition.py : -1 % 2 is  1
> In sage/combinat/partitions.pyx : -1 % 2 is  -1
> sage:
>
> Also, if this is file.pyx :
>
> # this is file.pyx
> cdef int aaa = -1
> tmp = aaa % 2
> print "In attached file.pyx : -1 % 2 is ", tmp
>
> then:
>
> sage: attach /tmp/file.pyx
> Compiling /tmp/file.pyx...
> In attached file.pyx : -1 % 2 is  1
>
> This -1 in sage library .pyx file is quite surprising to me. Is this a known
> issue?

Yes, we enable "c division" by default in the Sage library because
that was it was in old versions of Cython (and Pyrex), and some of the
library assumes these semantics for correctness. See
http://hg.sagemath.org/sage-main/file/45c4da67d234/setup.py#l741 and
http://wiki.cython.org/enhancements/division

It would be great to enable this directive solely on those files that
require it, so new code would not have to be aware of this difference,
but no one's taken the time to do this yet.

- Robert

-- 
-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org



Reply via email to