Repository: LMFDB/lmfdb

Issue:
Plot of L-functions of GL(3) Maass cusp forms is badly broken
On the page http://www.lmfdb.org/L/degree3/MaassForm/ the plot for level 4 cusp forms displays an image of an LMFDB page with a server error:

![image](https://cloud.githubusercontent.com/assets/11425002/16356943/50aacd22-3ab6-11e6-9002-b6ffc3460b7f.png)

This was working as of PR https://github.com/LMFDB/lmfdb/pull/1529 (June 9, 2016).

Plot of L-functions of GL(3) Maass cusp forms is badly broken
On the page http://www.lmfdb.org/L/degree3/MaassForm/ the plot for level 4 cusp forms displays an image of an LMFDB page with a server error:

![image](https://cloud.githubusercontent.com/assets/11425002/16356943/50aacd22-3ab6-11e6-9002-b6ffc3460b7f.png)

This was working as of PR https://github.com/LMFDB/lmfdb/pull/1529 (June 9, 2016).



Discussion:

Resolving patch:
diff --git a/lmfdb/lfunctions/LfunctionPlot.py b/lmfdb/lfunctions/LfunctionPlot.py
--- a/lmfdb/lfunctions/LfunctionPlot.py
+++ b/lmfdb/lfunctions/LfunctionPlot.py
@@ -8,7 +8,7 @@
 from lmfdb.modular_forms.elliptic_modular_forms.backend.web_modform_space import WebModFormSpace
 from lmfdb.characters.ListCharacters import get_character_modulus
 from lmfdb.lfunctions import logger
-from sage.all import prod
+from sage.all import prod, CC
 
 ###############################################################################
 # Maass form for GL(n) n>2
@@ -57,6 +57,8 @@ def getAllMaassGraphHtml(degree):
         groups = [ ["GL3", [1 , 4] ] ] 
     elif degree == 4:
         groups = [ ["GSp4", [1]], ["GL4", [1]] ] 
+    else:
+        return ""
 
     ans = ""
     for i in range(0, len(groups)):
@@ -812,7 +814,7 @@ def paintCSHoloTMP(width, height, xMax, yMax, xfactor, yfactor, ticlength):
 
 def signtocolour(sign):
     import cmath
-    argument = cmath.phase(float(sign))
+    argument = cmath.phase(CC(str(sign)))
     r = int(255.0 * (math.cos((1.0 * math.pi / 3.0) - (argument / 2.0))) ** 2)
     g = int(255.0 * (math.cos((2.0 * math.pi / 3.0) - (argument / 2.0))) ** 2)
     b = int(255.0 * (math.cos(argument / 2.0)) ** 2)
diff --git a/lmfdb/lfunctions/main.py b/lmfdb/lfunctions/main.py
--- a/lmfdb/lfunctions/main.py
+++ b/lmfdb/lfunctions/main.py
@@ -25,6 +25,11 @@
 from lmfdb import base
 from pymongo import ASCENDING
 
+def get_degree(degree_string):
+    if not re.match('degree[0-9]+',degree_string):
+        return -1
+    return int(degree_string[6:])
+
 ################################################################################
 #   Route functions, navigation pages
 ################################################################################
@@ -44,9 +49,6 @@ def l_function_history():
           (t, url_for('.l_function_history'))]
     return render_template(_single_knowl, title=t, kid='lfunction.history', body_class='', bread=bc)
 
-
-
-
 # Degree 1 L-functions browsing page ##############################################
 @l_function_page.route("/degree1/")
 def l_function_dirichlet_browse_page():
@@ -80,10 +82,9 @@ def l_function_degree4_browse_page():
 # Degree browsing page #########################################################
 @l_function_page.route("/<degree>/")
 def l_function_degree_page(degree):
-    res = re.match('degree[0-9]+',degree)
-    if not res:
+    degree = get_degree(degree)
+    if degree < 0:
         return flask.abort(404)
-    degree = res.group(0).atoi()
     info = {"degree": degree}
     info["key"] = 777
     info["bread"] = get_bread(degree, [])
@@ -118,10 +119,15 @@ def l_function_ec_browse_page():
 # L-function of GL(n) Maass forms browsing page ##############################################
 @l_function_page.route("/<degree>/MaassForm/")
 def l_function_maass_gln_browse_page(degree):
-    degree = int(degree[6:])
+    degree = get_degree(degree)
+    if degree < 0:
+        return flask.abort(404)
+    contents = LfunctionPlot.getAllMaassGraphHtml(degree)
+    if not contents:
+        return flask.abort(404)
     info = {"bread": get_bread(degree, [("MaassForm", url_for('.l_function_maass_gln_browse_page',
                                                               degree='degree' + str(degree)))])}
-    info["contents"] = LfunctionPlot.getAllMaassGraphHtml(degree)
+    info["contents"] = contents
     return render_template("MaassformGLn.html",
                            title='L-functions of GL(%s) Maass Forms' % degree, **info)
 
@@ -962,7 +968,6 @@ def render_zeroesLfunction(request, arg1, arg2, arg3, arg4, arg5, arg6, arg7, ar
     ''' Renders the first few zeroes of the L-function with the given arguments.
     '''
     L = generateLfunctionFromUrl(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, to_dict(request.args))
-
     if hasattr(L,"lfunc_data"):
         if L.lfunc_data is None:
             return "<span>" + L.zeros + "</span>"


Test patch: