#7604: Bug in continued fractions module (contfrac). Patch attached
---------------------------------------------------------+------------------
Reporter: solevillar | Owner:
AlexGhitza
Type: defect | Status: new
Priority: minor | Milestone:
Component: algebra | Keywords:
contfrac
Work_issues: | Author:
Upstream: Reported upstream. Little or no feedback. | Reviewer:
Merged: |
---------------------------------------------------------+------------------
I've found this bug in the contfrac module:
{{{
sage: a=continued_fraction(sqrt(2))
sage: a.qn(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_4.py", line 5, in <module>
a.qn(_sage_const_0 )
File "", line 1, in <module>
File "/usr/local/sage/local/lib/python2.6/site-
packages/sage/rings/contfrac.py", line 461, in qn
if len(self.__qn) < n+3:
AttributeError: 'ContinuedFraction' object has no attribute
'_ContinuedFraction__qn'
}}}
But this actually works:
{{{
sage: a=continued_fraction(sqrt(2))
sage: b=a.pn(0)
sage: a.qn(0)
1
}}}
That's because the method contfrac.pn initializes the attributes pn and qn
so if you call contfrac.qn before calling contfrac.pn the attribute qn
wont be initialized and that's why it doesn't work in the first snippet.
I wrote a patch that solves this problem (minor changes, very easy to
solve). I'm attaching that patch.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7604>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" 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/sage-trac?hl=en.