Hi Dima! Yes, we clearly overlooked that bug because we also tested on Sage itself, and never from just python. An easy fix to this would be the following in my opinion, so that everything gets coerced to Sage integers, irrespective of the input:
Q = Integer(q) kraw = jth_term = (Q-1)**l * binomial(n, l) # And replace all q with Q. everywhere else Regards, basu. On Mon, Nov 9, 2015 at 6:56 PM, Dima Pasechnik <[email protected]> wrote: > > > On Monday, 9 November 2015 07:19:45 UTC, Nils Bruin wrote: >> >> On Sunday, November 8, 2015 at 11:13:24 PM UTC-8, Nils Bruin wrote: >>> >>> >>> That's a bug, and one that should be pretty straightforward to solve. >> >> Indeed, it's exceedingly silly. In Krawtchouk we execute: >> >> jth_term *= -q*(l-j+1)*(i-j+1)/((q-1)*j*(n-j+1)) >> >> If we'de doing that division with Sage Integer then we'll be getting >> rational numbers. With python int this amounts to "//", so will likely give >> other answers. > > > I wrote that code a while ago, as an internal function, and the reviewer (hi > Basu!) insisted that I made it public. But me and he missed the argument > checking.... > > Dima > >> >> >> Workaround: make sure you input Sage Integers (i.e., if you absolutely >> have to use a ".py" file, write Integer(1) instead of 1. >> >> Fix: >> - for j in range(1,l+1): >> + for j in srange(1,l+1): >> >> >> -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
