Repository: LMFDB/lmfdb

Issue:
Problems with lcalc downloads for Dirichlet characters
I don't see how these are being reached (they are not shown on the L-function pages for Dirichlet character), but we are getting errors in flasklog triggered by robots trying to visit pages like:

http://www.lmfdb.org/L/Character/Dirichlet/103/85/?download=lcalcfile

In fact almost all the Dirichlet lcalc downloads don't work, e.g.

http://www.lmfdb.org/L/Character/Dirichlet/7/2/?download=lcalcfile

produces the same error.

This appears to be caused by createLcalcfile_ver2 in LfunctionLcalc.py trying to convert strings like "$e\left(\frac{2}{3}\right)$" to complex numbers.



Discussion:
Robots are still hitting these (a bunch occurred last night, although I do not think they are what caused the outage).

I believe that they were reachable at some point, and I guess that
webcrawlers put them on their todo list for later.

On 8 July 2016 at 23:51, Andrew Sutherland notifications@github.com wrote:

> Robots are still hitting these (a bunch occurred last night, although I do
> not think they are what caused the outage).
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> https://github.com/LMFDB/lmfdb/issues/1619#issuecomment-231364529, or mute
> the thread
> https://github.com/notifications/unsubscribe/AATtBiF3nqW8rgbW-2gVMCLyEViGkcbLks5qTlXXgaJpZM4JBJlD
> .

@AndrewVSutherland I can take a look at this and see if I can at least stop the exceptions from showing up in flasklog.

Fixed in PR #1695 (the problem was Dirichlet coeffs specified as strings e(m/n) (in fact as $e\left\frac{m}{n}\right)$.  string2number in Lfunctionutilities.py has been changed to handle these.

PR #1736, which fixed #1733 effectively undid PR #1695 which fixed this issue, which is now happening again.  I will integrate the two fixes and add a test case to make sure this doesn't happen again.


Resolving patch:
diff --git a/lmfdb/lfunctions/LfunctionLcalc.py b/lmfdb/lfunctions/LfunctionLcalc.py
--- a/lmfdb/lfunctions/LfunctionLcalc.py
+++ b/lmfdb/lfunctions/LfunctionLcalc.py
@@ -8,16 +8,14 @@
 
 
 def parse_complex_number(z):
-    """convert a string representing a complex number to another string
-    looking like "(x,y)"
-
+    """convert a string representing a complex number to another string looking like "(x,y)"
     """
     from sage.all import CC
     try:
         # need to convert from unicode to orginary string type
-        x,y = CC(str(z))
+        x,y = CC(string2number(str(z)))
         return "({},{})".format(x,y)
-    except TypeError:
+    except TypeError, SyntaxError:
         print("Unable to parse {} as complex number".format(z))
         return "(0,0)"
 


Test patch:
diff --git a/lmfdb/lfunctions/test_lfunctions.py b/lmfdb/lfunctions/test_lfunctions.py
--- a/lmfdb/lfunctions/test_lfunctions.py
+++ b/lmfdb/lfunctions/test_lfunctions.py
@@ -33,6 +33,12 @@ def test_LDirichlet(self):
         L = self.tc.get('L/Character/Dirichlet/1000000000000000000000/3/')
         assert 'too large' in L.data
 
+    def test_LcalcDirichlet(self):
+        L = self.tc.get('L/Character/Dirichlet/19/9/?download=lcalcfile')
+        assert 'lcalc file' in L.data
+        L = self.tc.get('L/Character/Dirichlet/6400/3/?download=lcalcfile')
+        assert 'lcalc file' in L.data
+
     def test_Lec(self):
         L = self.tc.get('/L/EllipticCurve/Q/11.a/')
         assert '0.2538418609' in L.data and 'Isogeny class 11.a' in L.data and 'Modular form 11.2a' in L.data and '/SatoTateGroup/1.2.' in L.data