Status: Accepted
Owner: [email protected]
CC: [email protected], asmeurer
Labels: Type-Defect Priority-High Milestone-Release0.7.2 Python3
Documentation
New issue 2605 by [email protected]: ntheory/factor_.py: doctest
incompatible with 2to3
http://code.google.com/p/sympy/issues/detail?id=2605
There's a doctest in ntheory/factor_.py which crashes the 2to3 tool when
ran on it. I've narrowed it down to a use of reduce() in the doctest,
here's the relevant codesnip:
Checking different ``a`` values shows that all the ones that
didn't
work had a gcd value not equal to ``n`` but equal to one of the
factors:
>>> from sympy.core.numbers import ilcm, igcd
>>> from sympy import factorint
>>> M = reduce(ilcm, range(2, 256))
>>> set([igcd(pow(a, M, n) - 1, n) for a in range(2, 256) if
... igcd(pow(a, M, n) - 1, n) != n])
set([1009])
But does aM % d for every divisor of n give 1?
>>> aM = pow(a, M, n)
>>> [(d, aM%(1*d)) for d in factorint(n, visual=True).args]
[(257**1, 1), (1009**1, 1)]
I've reported this issue upstream (see upstream issue 12611 [1]) but
whatever is done there we'll still have to support other Python versions so
we should find a way to rewrite the doctest (or remove it).
Now, I'm not familiar with the code at all, the doctests seems just to be
demonstrating some algorithm-specific quirk, so we could delete it if all
else fails (this is a hard crash after all). If the code could be rewritten
not to use reduce() that would be better, of course. Chris, I'm adding up
to CC: as I seen you're the author of the code; Aaron, could you add anyone
else who might be able to help? Thanks.
I'm putting this as High priority for the next milestone as it's a blocker
for py3k support.
[1] http://bugs.python.org/issue12611
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.