[Pyrex] is this a bug?

Robin Becker robin at reportlab.com
Sat Nov 24 14:13:06 CET 2007


I find in my learning project that the following code doesn't behave as 
expected in a python method

def compute_breakpoints(self,
                         line_lengths,
                         double looseness = 0,
                         double tolerance = 1,
                         double fitness_demerit = 100,
                         double flagged_demerit = 100,
			):
     cdef double r

     r = ......

     if -1 <= r <= tolerance:
         ......

r was printed out as -1.41176470588, but the if test succeeded. Correct 
behaviour was restored if either the double was removed from the 
tolerance argument or the test was rewritten as

     if -1.0 <= r <= tolerance:
-- 
Robin Becker



More information about the Pyrex mailing list