#13101: enumerate_totallyreal_fields bug fix
----------------------------------------------+----------------------------
Reporter: jvoight | Owner:
Type: defect | davidloeffler
Priority: major | Status:
Component: number fields | needs_review
Keywords: | Milestone: sage-5.11
Authors: Robert Harron, John Voight | Resolution:
Report Upstream: N/A | Merged in:
Branch: | Reviewers:
Stopgaps: | Work issues:
| Dependencies:
----------------------------------------------+----------------------------
Description changed by AlexGhitza:
Old description:
> sage: enumerate_totallyreal_fields_all(8, 10^8)
> ---------------------------------------------------------------------------
> IndexError Traceback (most recent call
> last)
>
> /home/jvoight/sage-4.2/devel/sage-main/sage/rings/number_field/<ipython
> console> in <module>()
>
> /usr/local/share/sage-5.0/local/lib/python2.7/site-
> packages/sage/rings/number_field/totallyreal_rel.pyc in
> enumerate_totallyreal_fields_all(n, B, verbose, return_seqs)
> 887 print "Taking F =", Sds[i][1]
> 888 F = NumberField(ZZx(Sds[i][1]), 't')
> --> 889 T = enumerate_totallyreal_fields_rel(F, n/d, B,
> verbose=verbose, return_seqs=return_seqs)
> 890 if return_seqs:
> 891 for i in range(3):
>
> /usr/local/share/sage-5.0/local/lib/python2.7/site-
> packages/sage/rings/number_field/totallyreal_rel.pyc in
> enumerate_totallyreal_fields_rel(F, m, B, a, verbose, return_seqs)
> 726 T.incr(f_out,verbose)
> 727 else:
> --> 728 T.incr(f_out)
> 729
> 730 Fx = PolynomialRing(F, 'xF')
>
> /usr/local/share/sage-5.0/local/lib/python2.7/site-
> packages/sage/rings/number_field/totallyreal_rel.pyc in incr(self, f_out,
> verbose, haltk)
> 542 # New bounds from Lagrange multiplier in
> degree 3.
>
> 543 bminmax =
> [lagrange_degree_3(m,v(self.a[m-1]),v(self.a[m-2]),v(self.a[m-3])) for v
> in self.Foo]
> --> 544 self.b_lower = [bminmax[i][0] for i in
> range(len(bminmax))]
> 545 self.b_upper = [bminmax[i][1] for i in
> range(len(bminmax))]
> 546
>
> IndexError: list index out of range
>
> The fix is easy: we just need to add the lines
>
> if len(z4minmax) < 1:
> z4minmax = [0.0, -1.0]
> [ return z4minmax ]
>
> before line 295 of sage/rings/number_field/totallyreal_data.pyx. (Yes,
> I'm still intimidated by creating a patch.)
>
> The issue was that when the lagrange multipliers gives contradictory
> bounds (a good thing, since it says the enumeration can stop in that
> branch), it was not sending a pair of bounds, just a single element,
> causing a type error.
>
> JV
New description:
{{{
sage: enumerate_totallyreal_fields_all(8, 10^8)
---------------------------------------------------------------------------
IndexError Traceback (most recent call
last)
/home/jvoight/sage-4.2/devel/sage-main/sage/rings/number_field/<ipython
console> in <module>()
/usr/local/share/sage-5.0/local/lib/python2.7/site-
packages/sage/rings/number_field/totallyreal_rel.pyc in
enumerate_totallyreal_fields_all(n, B, verbose, return_seqs)
887 print "Taking F =", Sds[i][1]
888 F = NumberField(ZZx(Sds[i][1]), 't')
--> 889 T = enumerate_totallyreal_fields_rel(F, n/d, B,
verbose=verbose, return_seqs=return_seqs)
890 if return_seqs:
891 for i in range(3):
/usr/local/share/sage-5.0/local/lib/python2.7/site-
packages/sage/rings/number_field/totallyreal_rel.pyc in
enumerate_totallyreal_fields_rel(F, m, B, a, verbose, return_seqs)
726 T.incr(f_out,verbose)
727 else:
--> 728 T.incr(f_out)
729
730 Fx = PolynomialRing(F, 'xF')
/usr/local/share/sage-5.0/local/lib/python2.7/site-
packages/sage/rings/number_field/totallyreal_rel.pyc in incr(self, f_out,
verbose, haltk)
542 # New bounds from Lagrange multiplier in
degree 3.
543 bminmax =
[lagrange_degree_3(m,v(self.a[m-1]),v(self.a[m-2]),v(self.a[m-3])) for v
in self.Foo]
--> 544 self.b_lower = [bminmax[i][0] for i in
range(len(bminmax))]
545 self.b_upper = [bminmax[i][1] for i in
range(len(bminmax))]
546
IndexError: list index out of range
}}}
The fix is easy: we just need to add the lines
{{{
if len(z4minmax) < 1:
z4minmax = [0.0, -1.0]
return z4minmax
}}}
before line 295 of sage/rings/number_field/totallyreal_data.pyx. (Yes,
I'm still intimidated by creating a patch.)
The issue was that when the lagrange multipliers gives contradictory
bounds (a good thing, since it says the enumeration can stop in that
branch), it was not sending a pair of bounds, just a single element,
causing a type error.
JV
--
--
Ticket URL: <http://trac.sagemath.org/ticket/13101#comment:5>
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 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-trac.
For more options, visit https://groups.google.com/groups/opt_out.