internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: LMFDB/lmfdb

Issue:
Some bianch modular forms are generating server errors
Here is the traceback for https://beta.lmfdb.org/ModularForm/GL2/ImaginaryQuadratic/2.0.163.1/900.1/a/
```
Exception on /ModularForm/GL2/ImaginaryQuadratic/2.0.163.1/900.1/a/ [GET]
Traceback (most recent call last):
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-9.3/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/bianchi_modular_forms/bianchi_modular_form.py", line 567, in render_bmf_webpage
    data = WebBMF.by_label(label, max_eigs=numeigs)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/bianchi_modular_forms/web_BMF.py", line 111, in by_label
    return WebBMF(data, max_eigs)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/bianchi_modular_forms/web_BMF.py", line 100, in __init__
    self.make_form(max_eigs)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/bianchi_modular_forms/web_BMF.py", line 235, in make_form
    curve_bc_parts = [split_lmfdb_label(lab) for lab in curve_bc]
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/bianchi_modular_forms/web_BMF.py", line 235, in <listcomp>
    curve_bc_parts = [split_lmfdb_label(lab) for lab in curve_bc]
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/elliptic_curves/web_ec.py", line 33, in split_lmfdb_label
    return lmfdb_label_regex.match(lab).groups()
AttributeError: 'NoneType' object has no attribute 'groups'
[2021-06-27 14:15:35 UTC] 500 error on URL https://beta.lmfdb.org/ModularForm/GL2/ImaginaryQuadratic/2.0.163.1/900.1/a/ ()
```


Discussion:
OK, I know what is causing this -- some BMFs do not have elliptic curves but the fairly short list of those which do not is hard-wired, and needs updating.

Resolving patch:
diff --git a/lmfdb/bianchi_modular_forms/web_BMF.py b/lmfdb/bianchi_modular_forms/web_BMF.py
--- a/lmfdb/bianchi_modular_forms/web_BMF.py
+++ b/lmfdb/bianchi_modular_forms/web_BMF.py
@@ -228,6 +228,7 @@ def conv(ap):
 
         curve_bc = db.ec_nfcurves.lucky({'class_label':self.label}, projection="base_change")
         if curve_bc is not None:
+            curve_bc = [lab for lab in curve_bc if '?' not in lab]
             if curve_bc and "." not in curve_bc[0]:
                 curve_bc = [cremona_label_to_lmfdb_label(lab) for lab in curve_bc]
             self.ec_status = 'exists'


Test patch:
Repository: LMFDB/lmfdb

Issue:
BMFs display AL eigenvalues in wrong order (sometimes)
In the table bmf_forms the Atkin-Lehner eigenvalues are stored in column AL_eigs as a list of integers (+1 or -1), one for each bad prime.  The issue is the order of the bad primes.  The data sorts these in the standard way (first by norm, then using the standard order of ideals of the same norm), but in the display code the list of bad primes is computed (line 155 of web_BMF.py) as self.level.prime_factors(), which does not necessarily sort the primes this way.

Example:  https://beta.lmfdb.org/ModularForm/GL2/ImaginaryQuadratic/2.0.3.1/192.1/a/.  The bad primes are P2=(2) of norm 4 and P3 of norm 3.  The AL eigenvalues are displayed showing +1 for P2 and -1 for P3 but these are in the wrong order (compare with the elliptic curve https://beta.lmfdb.org/EllipticCurve/2.0.3.1/192.1/a/1: the rule is that the AL eigenvalue is equal to the local root number).

Immediate fix: sort the list badp in the display code; not only sort by norm, but also sort within norm (the code is already in nfutils/psort.py).

Longer-term fix: precompute a list of bad primes in the correct order, and store in the table, to avoid factoring ideals on the fly.  (Sorry.)  It's a pity that this was not done when the column "level_bad_primes" was created and filled: note that this is only a list of the integer primes dividing the level norm.


Discussion:

Resolving patch:
diff --git a/lmfdb/bianchi_modular_forms/web_BMF.py b/lmfdb/bianchi_modular_forms/web_BMF.py
--- a/lmfdb/bianchi_modular_forms/web_BMF.py
+++ b/lmfdb/bianchi_modular_forms/web_BMF.py
@@ -3,7 +3,7 @@
 from lmfdb.logger import make_logger
 from lmfdb.number_fields.web_number_field import nf_display_knowl, field_pretty
 from lmfdb.elliptic_curves.web_ec import split_lmfdb_label
-from lmfdb.nfutils.psort import primes_iter, ideal_from_label, ideal_label
+from lmfdb.nfutils.psort import primes_iter, ideal_from_label, ideal_label, prime_key
 from lmfdb.utils import web_latex, names_and_urls, prop_int_pretty
 from lmfdb.lfunctions.LfunctionDatabase import (get_lfunction_by_url,
         get_instances_by_Lhash_and_trace_hash)
@@ -153,6 +153,7 @@ def conv(ap):
         self.level = ideal_from_label(K,self.level_label)
         self.level_ideal2 = web_latex(self.level)
         badp = self.level.prime_factors()
+        badp.sort(key=prime_key)
 
         self.nap = len(self.hecke_eigs)
         self.nap0 = min(nap0, self.nap)


Test patch:
Repository: LMFDB/lmfdb

Issue:
Table reload not working
All calls to the table reload method currently seem to fail with the error: `InvalidTableDefinition: multiple primary keys for table ... are not allowed`.

To reproduce:
```
db.test_table.copy_to("foo.txt")
db.test_table.reload("foo.txt")
```

@edgarcosta I expect this is  related to the recent change to sorting/id.  But I'm curious as to why you didn't hit this problem when you copied the gps_* tables to prod recently.  As  it  stands I can't copy any data to prod.


Discussion:
I will try to figure out what is going on on Monday.
But for the time being I managed to successfully reload with a very old commit fcb44ac5f29aa1f4da47ed2e0fbb2980f90cb288
@edgarcosta Thanks!
@edgarcosta Any progress on this?

Resolving patch:
diff --git a/lmfdb/backend/table.py b/lmfdb/backend/table.py
--- a/lmfdb/backend/table.py
+++ b/lmfdb/backend/table.py
@@ -1785,8 +1785,6 @@ def reload(
                 # tracks the success of resort
                 ordered = self.resort(suffix=suffix)
             else:
-               # We still need to build primary keys
-               self.restore_pkeys(suffix=suffix)
                ordered = False
 
 


Test patch:
Repository: LMFDB/lmfdb

Issue:
Cyclic isogeny degree search results
The search 
  http://www.lmfdb.org/EllipticCurve/Q/?count=None&hst=List&isogeny_degrees=200-300&search_type=List
for elliptic curves with a cyclic isogeny of degree 200-300 returns all elliptic curves?!  Actually, I get the same issue with input "5-6", but not with "37", so it must be interpreting ranged input incorrectly.

Also (whoever gets there), the knowl title "Bad $p$" also has a huge space in it between "Bad" and "$p$".


Discussion:

Resolving patch:
diff --git a/lmfdb/elliptic_curves/elliptic_curve.py b/lmfdb/elliptic_curves/elliptic_curve.py
--- a/lmfdb/elliptic_curves/elliptic_curve.py
+++ b/lmfdb/elliptic_curves/elliptic_curve.py
@@ -405,7 +405,7 @@ def elliptic_curve_search(info, query):
             query['cm'] = {'$ne' : 0}
         else:
             parse_ints(info,query,field='cm',qfield='cm')
-    parse_element_of(info,query,'isogeny_degrees',split_interval=1000,contained_in=get_stats().isogeny_degrees)
+    parse_element_of(info,query,'isogeny_degrees',split_interval=200,contained_in=get_stats().isogeny_degrees)
     parse_primes(info, query, 'nonmax_primes', name='non-maximal primes',
                  qfield='nonmax_primes', mode=info.get('nonmax_quantifier'), radical='nonmax_rad')
     parse_primes(info, query, 'bad_primes', name='bad primes',
@@ -893,7 +893,7 @@ def __init__(self):
         bad_primes = TextBoxWithSelect(
             name="bad_primes",
             label="Bad primes $p$",
-            short_label="Bad $p$",
+            short_label=r"Bad$\ p$",
             knowl="ec.q.reduction_type",
             example="5,13",
             select_box=bad_quant)
@@ -902,7 +902,7 @@ def __init__(self):
         sha_primes = TextBoxWithSelect(
             name="sha_primes",
             label="$p$ dividing |&#1064;|",
-            short_label="$p$ div |&#1064;|",
+            short_label="$p\ $div$\ $|&#1064;|",
             knowl="ec.analytic_sha_order",
             example="3,5",
             select_box=sha_quant)
@@ -938,7 +938,7 @@ def __init__(self):
         nonmax_primes = TextBoxWithSelect(
             name="nonmax_primes",
             label=r"Nonmaximal $\ell$",
-            short_label=r"Nonmax $\ell$",
+            short_label=r"Nonmax$\ \ell$",
             knowl="ec.maximal_elladic_galois_rep",
             example="2,3",
             select_box=nonmax_quant)
diff --git a/lmfdb/utils/search_parsing.py b/lmfdb/utils/search_parsing.py
--- a/lmfdb/utils/search_parsing.py
+++ b/lmfdb/utils/search_parsing.py
@@ -759,6 +759,8 @@ def parse_element_of(
         options = integer_options(
             inp, max_opts=split_interval, contained_in=contained_in
         )
+        if contained_in and len(options) == 0:
+            options = integer_options(inp,max_opts=split_interval)
         if len(options) == 1:
             query[qfield] = {"$contains": options}
         elif len(options) > 1:


Test patch:
Repository: LMFDB/lmfdb

Issue:
P-adic Galois group in gaga box incorrectly formatted
I haven't looked into this at all, but I see on pages like

https://www.lmfdb.org/padicField/2.12.30.284

that the gaga box "Galois group" property misrenders `galois_group[tex_name]`.


Discussion:

Resolving patch:
diff --git a/lmfdb/galois_groups/transitive_group.py b/lmfdb/galois_groups/transitive_group.py
--- a/lmfdb/galois_groups/transitive_group.py
+++ b/lmfdb/galois_groups/transitive_group.py
@@ -115,7 +115,7 @@ def display_short(self, emptyifnotpretty=False):
         gp_label = f"{self.order()}.{self.gapid()}"
         group = db.gps_groups.lookup(gp_label)
         if group and group.get('tex_name'):
-            return "${group['tex_name']}$"
+            return f"${group['tex_name']}$"
         if emptyifnotpretty:
             return ""
         return self._data['name']


Test patch:
Repository: LMFDB/lmfdb

Issue:
Coefficients of the q-expansion not properly defined
For this weight 1 modular form
https://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/1487/1/b/a/
we say
```Coefficients of the $q$-expansion are expressed in terms of a basis $1,\beta_1,\ldots,\beta_{17}$ for the coefficient ring described below.``` 
but we never end up saying what $\beta_i$ are.


Discussion:
I don't understand why the basis is not being displayed, it is in the [data](https://beta.lmfdb.org/api/mf_hecke_nf/79440), with power_basis set to False, so it should be getting displayed.

Resolving patch:
diff --git a/lmfdb/classical_modular_forms/web_newform.py b/lmfdb/classical_modular_forms/web_newform.py
--- a/lmfdb/classical_modular_forms/web_newform.py
+++ b/lmfdb/classical_modular_forms/web_newform.py
@@ -172,7 +172,6 @@ def __init__(self, data, space=None, all_m = False, all_n = False, embedding_lab
                     zero = []
                 self.qexp = [zero] + eigenvals['an']
                 self.qexp_prec = len(self.qexp)
-                m = self.field_poly_root_of_unity
                 self.single_generator = self.hecke_ring_power_basis or (self.dim == 2)
                 # This is not enough, for some reason
                 #if (m != 0) and (not self.single_generator):


Test patch:
Repository: LMFDB/lmfdb

Issue:
Problem with zeta zeroes download script
The python script at https://github.com/LMFDB/lmfdb/blob/master/lmfdb/zeros/zeta/platt_zeros.py created by David Platt to parse downloaded zeta zeros files seems to no longer work correctly, possibly because of missing a file `index.db` that should be in the download directory at https://beta.lmfdb.org/data/riemann-zeta-zeros/.

One can work around this problem by applying the following changes

Change #1
- line 70 in the code was " infile.seek(offset, 0)"
- changed line 70 to " infile.seek(offset, 1)"

Change #2
- using sqlite3, create table "zero_index"
- in table "zero_index" insert columns "t, N, filename, offset, block_number"
- add a row to the zero_index table for each file you want to read (e.g. "1, 1, 'zeros_14.dat', 0, 1" for the first file)

We should recover or recreate the missing index file and/or modify the script platt_zeros.py as required so that it works correctly without any changes.



Discussion:

Resolving patch:
diff --git a/lmfdb/zeros/zeta/zetazeros.py b/lmfdb/zeros/zeta/zetazeros.py
--- a/lmfdb/zeros/zeta/zetazeros.py
+++ b/lmfdb/zeros/zeta/zetazeros.py
@@ -21,7 +21,7 @@ def friends_list():
     return [('L-function', url_for("l_functions.l_function_riemann_page"))]
 
 def downloads():
-    return [('Bulk download', "https://beta.lmfdb.org/data/riemann-zeta-zeros/")]
+    return [('Bulk download', "https://beta.lmfdb.org/riemann-zeta-zeros/")]
 
 # Return the learnmore list with the matchstring entry removed
 def learnmore_list_remove(matchstring):


Test patch:
Repository: LMFDB/lmfdb

Issue:
"raw_typeset undefined" error on sibling fields that have a polynomial but no label
The number field knowls in the sibling data do not work properly in cases where a defining polynomial for the sibling field is known but the sibling field itself is not in the LMFDB,

Click on the "Deg 12" link in the list of sibling fields on https://www.lmfdb.org/NumberField/5.5.106588382947225.1 to reproduce: you will see a knowl with the error message

`ERROR in the template: 'raw_typeset' is undefined. Please edit it to resolve the problem.`

I'm sure this is easy to fix, I'm just not sure exactly where the fix needs to be made.


Discussion:
I think we are forgetting to make raw_typeset exposed to Jinja, as we other
functions that we use in knowls

On Thu, Jul 14, 2022, 04:26 Andrew Sutherland ***@***.***>
wrote:

> The number field knowls in the sibling data do not work properly in cases
> where a defining polynomial for the sibling field is known but the sibling
> field itself is not in the LMFDB,
>
> Click on the "Deg 12" link in the list of sibling fields on
> https://www.lmfdb.org/NumberField/5.5.106588382947225.1 to reproduce: you
> will see a knowl with the error message
>
> ERROR in the template: 'raw_typeset' is undefined. Please edit it to
> resolve the problem.
>
> I'm sure this is easy to fix, I'm just not sure exactly where the fix
> needs to be made.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/LMFDB/lmfdb/issues/5159>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACO2BURW62OA27S7NMM7ILVT7TMXANCNFSM53RXYZFA>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


Resolving patch:
diff --git a/lmfdb/number_fields/number_field.py b/lmfdb/number_fields/number_field.py
--- a/lmfdb/number_fields/number_field.py
+++ b/lmfdb/number_fields/number_field.py
@@ -93,6 +93,10 @@ def fixed_prec(r, digs=3):
     print(head)
     return str(head) + '.' + n[-digs:]
 
+@app.context_processor
+def ctx_raw_typeset():
+    return {'raw_typeset': raw_typeset}
+
 
 @app.context_processor
 def ctx_galois_groups():


Test patch:
Repository: LMFDB/lmfdb

Issue:
PIP dependencies
We have several deprecated dependencies that we should fix ASAP
```
flask<=1.1.4
markupsafe<=2.0.1
itsdangerous<=2.0.1
```

in particular, this prevents using lmfdb in an environment with jupyterlab installed, which is something we would like to have working on a short time basis. 


Discussion:

Resolving patch:
diff --git a/lmfdb/local_fields/__init__.py b/lmfdb/local_fields/__init__.py
--- a/lmfdb/local_fields/__init__.py
+++ b/lmfdb/local_fields/__init__.py
@@ -27,7 +27,6 @@ def redirect_local():
 
 
 app.register_blueprint(local_fields_page, url_prefix="/padicField")
-app.register_blueprint(local_fields_page, url_prefix="/LocalNumberField")
 
 # API2 has been disabled for now
 #from lmfdb.api2.searchers import register_search_function


Test patch:
Repository: LMFDB/lmfdb

Issue:
Incorrect data in mod ell images of Galois representations
I am reporting something noted to me by Abbey Bourdon.

Look at a page like https://www.lmfdb.org/EllipticCurve/Q/338/b/1. Under `Galois representations`, in the table indicating primes where the mod ell Galois representations, the data for 5B (at https://www.lmfdb.org/knowledge/show/gl2.subgroup_data?label=5B) indicates that -1 is not in this subgroup. But this is the whole Borel subgroup, which certainly contains -1.


Discussion:
Thanks! I will fix this.
> Thanks! I will fix this.

Is the knowl for 5B incorrect, or is 5B the wrong label for the image for that curve?  If the latter, there may be more incorrect entries.
It's the knowl that's incorrect here. There are couple of other knowls where this happens too, like [5B.4.1](https://www.lmfdb.org/knowledge/show/gl2.subgroup_data?label=5B.4.1).

Resolving patch:
diff --git a/lmfdb/elliptic_curves/web_ec.py b/lmfdb/elliptic_curves/web_ec.py
--- a/lmfdb/elliptic_curves/web_ec.py
+++ b/lmfdb/elliptic_curves/web_ec.py
@@ -101,7 +101,7 @@ def ratcusps(c, r):
         return f" (of which {r} are rational)"
 
     info += row_wrap('Cusps', "%s%s" % (data['cusps'], ratcusps(data['cusps'],data['rational_cusps'])))
-    info += row_wrap('Contains $-1$', "yes" if data['quadratic_twists'][0] == label else "no")
+    info += row_wrap('Contains $-1$', "yes" if data['quadratic_twists'][0] == data['label'] else "no")
     if label != data['label']:
         info += row_wrap('LMFDB label', data['label'])
     if data.get('CPlabel'):


Test patch:
Repository: LMFDB/lmfdb

Issue:
Incorrect data in mod ell images of Galois representations
I am reporting something noted to me by Abbey Bourdon.

Look at a page like https://www.lmfdb.org/EllipticCurve/Q/338/b/1. Under `Galois representations`, in the table indicating primes where the mod ell Galois representations, the data for 5B (at https://www.lmfdb.org/knowledge/show/gl2.subgroup_data?label=5B) indicates that -1 is not in this subgroup. But this is the whole Borel subgroup, which certainly contains -1.


Discussion:

Resolving patch:
diff --git a/lmfdb/elliptic_curves/web_ec.py b/lmfdb/elliptic_curves/web_ec.py
--- a/lmfdb/elliptic_curves/web_ec.py
+++ b/lmfdb/elliptic_curves/web_ec.py
@@ -101,7 +101,7 @@ def ratcusps(c, r):
         return f" (of which {r} are rational)"
 
     info += row_wrap('Cusps', "%s%s" % (data['cusps'], ratcusps(data['cusps'],data['rational_cusps'])))
-    info += row_wrap('Contains $-1$', "yes" if data['quadratic_twists'][0] == label else "no")
+    info += row_wrap('Contains $-1$', "yes" if data['quadratic_twists'][0] == data['label'] else "no")
     if label != data['label']:
         info += row_wrap('LMFDB label', data['label'])
     if data.get('CPlabel'):
diff --git a/lmfdb/utils/config.py b/lmfdb/utils/config.py
--- a/lmfdb/utils/config.py
+++ b/lmfdb/utils/config.py
@@ -113,7 +113,7 @@ def __init__(self, writeargstofile=False, readargs=False):
             "--restart",
             action="store_true",
             dest="core_restart",
-            help="enable restart mode",
+            help="enable restart mode. CAUTION: can cause segfaults on pages using PARI",
         )
 
         parser.add_argument(
diff --git a/lmfdb/website.py b/lmfdb/website.py
--- a/lmfdb/website.py
+++ b/lmfdb/website.py
@@ -8,7 +8,7 @@
 # version 2 of the License, or (at your option) any later version.
 """
 start this via $ sage -python website.py --port <portnumber>
-add --debug if you are developing (auto-restart, full stacktrace in browser, ...)
+add --debug if you are developing (full stacktrace in browser, ...)
 """
 
 # Needs to be done first so that other modules and gunicorn can use logging


Test patch:
Repository: LMFDB/lmfdb

Issue:
gp code for polynomials
When asking for gp code, the polynomials are constructed with `Pol(Vecrev([ ... ]))`. There is a shortcut called `Polrev([ ... ])`, which would produce slightly nicer code.


Discussion:

Resolving patch:
diff --git a/lmfdb/ecnf/WebEllipticCurve.py b/lmfdb/ecnf/WebEllipticCurve.py
--- a/lmfdb/ecnf/WebEllipticCurve.py
+++ b/lmfdb/ecnf/WebEllipticCurve.py
@@ -841,7 +841,7 @@ def make_code(label, lang=None):
     ainvs_string = {
         'magma': "[" + ",".join("K!{}".format(ai) for ai in ainvs) + "]",
         'sage': "[" + ",".join("K({})".format(ai) for ai in ainvs) + "]",
-        'pari': "[" + ",".join("Pol(Vecrev({}))".format(ai) for ai in ainvs) + "], K",
+        'pari': "[" + ",".join("Polrev({})".format(ai) for ai in ainvs) + "], K",
         }
     if lang:
         Ecode['curve'] = Ecode['curve'] % ainvs_string[lang]


Test patch:
Repository: LMFDB/lmfdb

Issue:
Knowl category links not working
If you go to https://www.lmfdb.org/knowledge/ and click on a category link (e.g. `artin(23)`) nothing happens.  The href in this case is
```
<a href="#" onclick="$('#catinp').val('artin'); $('#knowl-search').submit(); return false;">artin(23) </a>
```
Tested on chrome and firefox.


Discussion:

Resolving patch:
diff --git a/lmfdb/knowledge/main.py b/lmfdb/knowledge/main.py
--- a/lmfdb/knowledge/main.py
+++ b/lmfdb/knowledge/main.py
@@ -300,17 +300,6 @@ def get_bread(breads=[]):
     return bc
 
 
-def searchbox(q="", clear=False):
-    """returns the searchbox"""
-    searchbox = u"""\
-    <form id='knowl-search' action="%s" method="GET">
-      <input name="search" value="%s" />"""
-    if clear:
-        searchbox += '<a href="%s">clear</a>' % url_for(".index")
-    searchbox += '<button type="submit">Go</button>'
-    searchbox += "</form>"
-    return searchbox % (url_for(".index"), q)
-
 
 @knowledge_page.route("/test")
 def test():


Test patch: