Repository: LMFDB/lmfdb

Issue:
Euler factor terms displayed in the wrong order on rational L-function CMF
On the L-function page

    http://www.lmfdb.com/L/ModularForm/GL2/Q/holomorphic/2401/2/a/f/

The 675*p^3T^12 term of the Euler factor at 2 appears before the 147p^5T^11 term, and a similar problems appear in the Euler factor at 3 for the T^5 and T^6 terms.

It appears that the terms are being ordered base on the total degree in p and T, rather than the degree in T (this should be an easy fix).



Discussion:

Resolving patch:
diff --git a/lmfdb/utils/utilities.py b/lmfdb/utils/utilities.py
--- a/lmfdb/utils/utilities.py
+++ b/lmfdb/utils/utilities.py
@@ -23,12 +23,16 @@
 from markupsafe import Markup, escape
 from werkzeug.contrib.cache import SimpleCache
 from werkzeug import cached_property
-from sage.all import CC, CBF, CDF, Factorization, NumberField, PolynomialRing, PowerSeriesRing, RealField, RR, RIF, ZZ, QQ, latex, valuation, prime_range, floor
+from sage.all import (CC, CBF, CDF,
+                      Factorization, NumberField,
+                      PolynomialRing, PowerSeriesRing, QQ,
+                      RealField, RR, RIF, TermOrder, ZZ)
+from sage.all import floor, latex, prime_range, valuation
 from sage.structure.element import Element
 
 from lmfdb.app import app, is_beta, is_debug_mode, _url_source
 
-def list_to_factored_poly_otherorder(s, galois=False, vari = 'T', p = None):
+def list_to_factored_poly_otherorder(s, galois=False, vari='T', p=None):
     """
         Either return the polynomial in a nice factored form,
         or return a pair, with first entry the factored polynomial
@@ -50,7 +54,7 @@ def list_to_factored_poly_otherorder(s, galois=False, vari = 'T', p = None):
     sfacts_fc_list = [[(-g).list() if g[0] == -1 else g.list(), e] for g, e in sfacts_fc]
     return list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois, vari, p)
 
-def list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois=False, vari = 'T', p = None):
+def list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois=False, vari='T', p=None):
     """
         Either return the polynomial in a nice factored form,
         or return a pair, with first entry the factored polynomial
@@ -58,8 +62,9 @@ def list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois=False, vari
         of the factors.
         vari allows to choose the variable of the polynomial to be returned.
     """
-    gal_list=[]
-    ZZpT  = PolynomialRing(ZZ, ['p',vari], order = 'negdeglex')
+    gal_list = []
+    order = TermOrder('M(0,-1,0,-1)')
+    ZZpT = PolynomialRing(ZZ, ['p', vari], order=order)
     ZZT = PolynomialRing(ZZ, vari)
     outstr = ''
     for g, e in sfacts_fc_list:
@@ -74,12 +79,12 @@ def list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois=False, vari
 
         # casting from ZZT -> ZZpT
         if p is None:
-            gtoprint = dict( zip( zip( [0]*len(g), range(len(g))), g) )
+            gtoprint = dict(zip(zip([0]*len(g), range(len(g))), g))
         else:
             gtoprint = {}
             for i, elt in enumerate(g):
                 if elt != 0:
-                    val =  ZZ(elt).valuation(p)
+                    val = ZZ(elt).valuation(p)
                     gtoprint[(val, i)] = elt/p**val
         glatex = latex(ZZpT(gtoprint))
         if  e > 1:
@@ -91,11 +96,11 @@ def list_factored_to_factored_poly_otherorder(sfacts_fc_list, galois=False, vari
 
     if galois:
         # 2 factors of degree 2
-        if len(sfacts_fc_list)==2:
+        if len(sfacts_fc_list) == 2:
             if len(sfacts_fc_list[0][0]) == 3 and len(sfacts_fc_list[1][0]) == 3:
                 troubletest = ZZT(sfacts_fc_list[0][0]).disc()*ZZT(sfacts_fc_list[1][0]).disc()
                 if troubletest.is_square():
-                    gal_list=[[2,1]]
+                    gal_list = [[2, 1]]
         return outstr, gal_list
     return outstr
 


Test patch: