Repository: LMFDB/lmfdb

Issue:
Possible: modular form labelled as cm is not cm
This came in via the feedback page.  There was no e-mail address, so just fix it or mark it as invalid.

http://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/15/2/1/a/

is marked as CM.  The commenter says it is not CM, but is Steinberg at 3 and 5.



Discussion:
Indeed, this is not a CM form.
I will look at it.

> On Feb 29, 2016, at 10:16, John Jones notifications@github.com wrote:
> 
> This came in via the feedback page. There was no e-mail address, so just fix it or mark it as invalid.
> 
> http://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/15/2/1/a/ http://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/15/2/1/a/
> is marked as CM. The commenter says it is not CM, but is Steinberg at 3 and 5.
> 
> —
> Reply to this email directly or view it on GitHub https://github.com/LMFDB/lmfdb/issues/787.


Resolving patch:
diff --git a/lmfdb/modular_forms/elliptic_modular_forms/backend/web_newforms.py b/lmfdb/modular_forms/elliptic_modular_forms/backend/web_newforms.py
--- a/lmfdb/modular_forms/elliptic_modular_forms/backend/web_newforms.py
+++ b/lmfdb/modular_forms/elliptic_modular_forms/backend/web_newforms.py
@@ -231,8 +231,12 @@ def max_coefficient_in_db(self):
         recs = self._collection.find({'hecke_orbit_label':self.hecke_orbit_label})
         if recs.count()==0:
             return 0
-        prec_in_db = max(rec['prec'] for rec in recs)
-        return next_prime(prec_in_db)-1
+        prec_in_db = [rec['prec'] for rec in recs]
+        if prec_in_db != []:
+            max_prec_in_db = max(prec_in_db)
+            return next_prime(max_prec_in_db)-1
+        else:
+            return 0
         
     def __getitem__(self, p):
         if self.auto_update and not self.has_eigenvalue(p):
@@ -301,7 +305,7 @@ def __init__(self, level=1, weight=12, character=1, label='a', prec=None, parent
             WebNumberField('coefficient_field'),
             WebInt('coefficient_field_degree'),
             WebList('twist_info', required = False),
-            WebBool('is_cm', required = False),
+            WebInt('is_cm', required = False),
             WebInt('cm_disc', required = False, default_value=0),
             WebDict('_cm_values',required=False),
             WebBool('is_cuspidal',default_value=True),
diff --git a/lmfdb/modular_forms/elliptic_modular_forms/backend/web_object.py b/lmfdb/modular_forms/elliptic_modular_forms/backend/web_object.py
--- a/lmfdb/modular_forms/elliptic_modular_forms/backend/web_object.py
+++ b/lmfdb/modular_forms/elliptic_modular_forms/backend/web_object.py
@@ -20,7 +20,7 @@
 AUTHORS:
 
  - Stephan Ehlen
- 
+ - Fredrik Stromberg 
 """
 from lmfdb.base import app
 from flask import url_for
@@ -35,6 +35,7 @@
 import pymongo
 import gridfs
 import re
+import datetime
 
 class WebProperty(object):
     r"""
@@ -515,6 +516,8 @@ def save_to_db(self, update = True):
         #key.update(file_key)
         #print meta_key
         dbd = self.db_dict()
+        ## Add modification data
+        dbd['modification_date'] = datetime.datetime.utcnow()
         #emf_logger.debug("update with dbd={0} and key:{1}".format(dbd,key))
         #meta['fid'] = fid
         if coll.find(key).count()>0:
@@ -686,7 +689,7 @@ def __init__(self, **kwargs):
 
 # Define some simple data types with reasonable default values
 
-import datetime
+
 class WebDate(WebProperty):
     _default_value = datetime.datetime(1970, 1, 1, 0, 0)
 
diff --git a/lmfdb/modular_forms/elliptic_modular_forms/views/emf_render_web_newform.py b/lmfdb/modular_forms/elliptic_modular_forms/views/emf_render_web_newform.py
--- a/lmfdb/modular_forms/elliptic_modular_forms/views/emf_render_web_newform.py
+++ b/lmfdb/modular_forms/elliptic_modular_forms/views/emf_render_web_newform.py
@@ -206,14 +206,14 @@ def set_info_for_web_newform(level=None, weight=None, character=None, label=None
         if CM.has_key('tau') and len(CM['tau']) != 0:
             info['CM_values'] = CM
     info['is_cm'] = WNF.is_cm
-    if WNF.is_cm:
+    if WNF.is_cm == 1:
         info['cm_field'] = "2.0.{0}.1".format(-WNF.cm_disc)
         info['cm_disc'] = WNF.cm_disc
         info['cm_field_knowl'] = nf_display_knowl(info['cm_field'], getDBConnection(), field_pretty(info['cm_field']))
         info['cm_field_url'] = url_for("number_fields.by_label", label=info["cm_field"])
-    if WNF.is_cm is None:
+    if WNF.is_cm is None or WNF.is_cm==-1:
         s = '- Unknown (insufficient data)<br>'
-    elif WNF.is_cm:
+    elif WNF.is_cm == 1:
         s = 'Is a CM-form<br>'
     else:
         s = 'Is not a CM-form<br>'


Test patch: