def todays_curve(): from datetime import date mordells_birthday = date(1888,1,28) n = (date.today()-mordells_birthday).days label = db_ec().find({'number' : int(1)})[n]['label'] #return render_curve_webpage_by_label(label) return redirect(url_for(".by_ec_label", label=label), 307)
def download_EC_all(label): try: N, iso, number = split_lmfdb_label(label) except (ValueError,AttributeError): return elliptic_curve_jump_error(label, {}) CDB = db_ec() if number: data = CDB.find_one({'lmfdb_label': label}) if data is None: return elliptic_curve_jump_error(label, {}) data_list = [data] else: data_list = sorted(list(CDB.find({'lmfdb_iso': label})), key=lambda E: E['number']) if len(data_list) == 0: return elliptic_curve_jump_error(label, {}) # For each curve we will output all data fields except the '_id': # (This should also be possible by adding projection={'_id':False} # to the find() call but on testing that timed out.) for data in data_list: data.pop('_id') import json response = make_response('\n\n'.join(json.dumps(d) for d in data_list)) response.headers['Content-type'] = 'text/plain' return response
def download_EC_qexp(label, limit): CDB = db_ec() N, iso, number = split_lmfdb_label(label) if number: data = CDB.find_one({'lmfdb_label': label}) else: data = CDB.find_one({'lmfdb_iso': label}) E = EllipticCurve(parse_ainvs(data['ainvs'])) response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True))) response.headers['Content-type'] = 'text/plain' return response
def by_weierstrass(eqn): w = weierstrass_eqn_regex.match(eqn) if not w: w = short_weierstrass_eqn_regex.match(eqn) if not w: return elliptic_curve_jump_error(eqn, {}) try: ainvs = [ZZ(ai) for ai in w.groups()] except TypeError: return elliptic_curve_jump_error(eqn, {}) E = EllipticCurve(ainvs).global_minimal_model() N = E.conductor() ainvs = [str(ai) for ai in E.ainvs()] xainvs = ''.join(['[',','.join(ainvs),']']) data = db_ec().find_one({'xainvs': xainvs}) if data is None: data = db_ec().find_one({'ainvs': ainvs}) if data is None: return elliptic_curve_jump_error(eqn, {'conductor':N}, missing_curve=True) return redirect(url_for(".by_ec_label", label=data['lmfdb_label']), 301)
def download_search(info): dltype = info['Submit'] delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on %s.\n' % ( mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [Weierstrass Coefficients]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'data := [' else: s += 'data = [' s += '\\\n' # reissue saved query here res = db_ec().find(ast.literal_eval(info["query"])) for f in res: entry = str(f['ainvs']) entry = entry.replace('u', '') entry = entry.replace('\'', '') s += entry + ',\\\n' s = s[:-3] s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def download_search(info): dltype = info['Submit'] delim = 'bracket' com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' delim = 'magma' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on %s.\n'%(mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [Weierstrass Coefficients]\n' s += '\n' + com2 s += '\n' if dltype == 'magma': s += 'data := [' else: s += 'data = [' s += '\\\n' # reissue saved query here res = db_ec().find(ast.literal_eval(info["query"])) for f in res: entry = str(f['ainvs']) entry = entry.replace('u','') entry = entry.replace('\'','') s += entry + ',\\\n' s = s[:-3] s += ']\n' if delim == 'brace': s = s.replace('[', '{') s = s.replace(']', '}') if delim == 'magma': s = s.replace('[', '[*') s = s.replace(']', '*]') s += ';' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def plot_ec(label): CDB = db_ec() data = CDB.find_one({'lmfdb_label': label}) if data is None: return elliptic_curve_jump_error(label, {}) E = EllipticCurve(parse_ainvs(data['xainvs'])) P = E.plot() _, filename = tempfile.mkstemp('.png') P.save(filename) data = open(filename).read() os.unlink(filename) response = make_response(data) response.headers['Content-type'] = 'image/png' return response
def by_ec_label(label): ec_logger.debug(label) # First see if we have an LMFDB label of a curve or class: try: N, iso, number = split_lmfdb_label(label) if number: return redirect( url_for(".by_triple_label", conductor=N, iso_label=iso, number=number)) else: return redirect( url_for(".by_double_iso_label", conductor=N, iso_label=iso)) except AttributeError: ec_logger.debug("%s not a valid lmfdb label, trying cremona") # Next see if we have a Cremona label of a curve or class: try: N, iso, number = split_cremona_label(label) except AttributeError: ec_logger.debug( "%s not a valid cremona label either, trying Weierstrass") eqn = label.replace(" ", "") if weierstrass_eqn_regex.match( eqn) or short_weierstrass_eqn_regex.match(eqn): return by_weierstrass(eqn) else: return elliptic_curve_jump_error(label, {}) if number: # it's a curve label_type = 'label' else: label_type = 'iso' data = db_ec().find_one({label_type: label}) if data is None: return elliptic_curve_jump_error(label, {}) ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label'])) iso = data['lmfdb_iso'].split(".")[1] if number: return redirect( url_for(".by_triple_label", conductor=N, iso_label=iso, number=data['lmfdb_number'])) else: return redirect( url_for(".by_double_iso_label", conductor=N, iso_label=iso))
def isogeny_class_table(Nmin, Nmax): ''' Returns a table of all isogeny classes of elliptic curves with conductor in the ranges NMin, NMax. ''' iso_list = [] query = {'number': 1, 'conductor': {'$lte': Nmax, '$gte': Nmin}} # Get all the curves and sort them according to conductor cursor = db_ec().find(query,{'_id':False,'conductor':True,'lfmdb_label':True,'lmfdb_iso':True}) res = cursor.sort([('conductor', ASCENDING), ('lmfdb_label', ASCENDING)]) iso_list = [E['lmfdb_iso'].split('.') for E in res] return iso_list
def by_label(label): """ Searches for a specific elliptic curve isogeny class in the curves collection by its label, which can be either a curve label (e.g. "11.a1") or a class label (e.g. "11.a") in either LMFDB or Cremona format. """ try: N, iso, number = split_lmfdb_label(label) if number: label = ".".join([N,iso]) data = db_ec().find_one({"lmfdb_iso" : label, 'number':1}) except AttributeError: try: N, iso, number = split_cremona_label(label) if number: label = "".join([N,iso]) data = db_ec().find_one({"iso" : label, 'number':1}) except AttributeError: return "Invalid label" # caller must catch this and raise an error if data: return ECisog_class(data) return "Class not found" # caller must catch this and raise an error
def isogeny_class_table(Nmin, Nmax): ''' Returns a table of all isogeny classes of elliptic curves with conductor in the ranges NMin, NMax. ''' iso_list = [] query = {'number': 1, 'conductor': {'$lte': Nmax, '$gte': Nmin}} # Get all the curves and sort them according to conductor cursor = db_ec().find(query,{'_id':False,'conductor':True,'lfmdb_label':True,'lmfdb_iso':True}) res = cursor.sort([('conductor', ASCENDING), ('lmfdb_label', ASCENDING)]) iso_list = [E['lmfdb_iso'] for E in res] return iso_list
def modular_form_display(label, number): try: number = int(number) except ValueError: number = 10 if number < 10: number = 10 if number > 1000: number = 1000 data = db_ec().find_one({'lmfdb_label': label}) if data is None: return elliptic_curve_jump_error(label, {}) E = EllipticCurve(parse_ainvs(data['xainvs'])) modform = E.q_eigenform(number) modform_string = web_latex_split_on_pm(modform) return modform_string
def by_ec_label(label): ec_logger.debug(label) # First see if we have an LMFDB label of a curve or class: try: N, iso, number = split_lmfdb_label(label) if number: return redirect(url_for(".by_triple_label", conductor=N, iso_label=iso, number=number)) else: return redirect(url_for(".by_double_iso_label", conductor=N, iso_label=iso)) except AttributeError: ec_logger.debug("%s not a valid lmfdb label, trying cremona") # Next see if we have a Cremona label of a curve or class: try: N, iso, number = split_cremona_label(label) except AttributeError: ec_logger.debug("%s not a valid cremona label either, trying Weierstrass") eqn = label.replace(" ","") if weierstrass_eqn_regex.match(eqn) or short_weierstrass_eqn_regex.match(eqn): return by_weierstrass(eqn) else: return elliptic_curve_jump_error(label, {}) if number: # it's a curve label_type = 'label' else: label_type = 'iso' data = db_ec().find_one({label_type: label}) if data is None: return elliptic_curve_jump_error(label, {}) ec_logger.debug(url_for(".by_ec_label", label=data['lmfdb_label'])) iso = data['lmfdb_iso'].split(".")[1] if number: return redirect(url_for(".by_triple_label", conductor=N, iso_label=iso, number=data['lmfdb_number'])) else: return redirect(url_for(".by_double_iso_label", conductor=N, iso_label=iso))
def download_search(info): dltype = info['Submit'] com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end ass = '=' # assignment eol = '' # end of line filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' ass = ":=" eol = ';' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on {}.\n'.format( mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [a1,a2,a3,a4,a6] (Weierstrass Coefficients)\n' s += '\n' + com2 + '\n' s += 'data ' + ass + ' [' + '\\\n' # reissue saved query here res = db_ec().find(ast.literal_eval(info["query"])) s += ",\\\n".join([str(f['xainvs']) for f in res]) s += ']' + eol + '\n' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def download_search(info): dltype = info['Submit'] com = r'\\' # single line comment start com1 = '' # multiline comment start com2 = '' # multiline comment end ass = '=' # assignment eol = '' # end of line filename = 'elliptic_curves.gp' mydate = time.strftime("%d %B %Y") if dltype == 'sage': com = '#' filename = 'elliptic_curves.sage' if dltype == 'magma': com = '' com1 = '/*' com2 = '*/' ass = ":=" eol = ';' filename = 'elliptic_curves.m' s = com1 + "\n" s += com + ' Elliptic curves downloaded from the LMFDB downloaded on {}.\n'.format(mydate) s += com + ' Below is a list called data. Each entry has the form:\n' s += com + ' [a1,a2,a3,a4,a6] (Weierstrass Coefficients)\n' s += '\n' + com2 + '\n' s += 'data ' + ass + ' [' + '\\\n' # reissue saved query here res = db_ec().find(ast.literal_eval(info["query"])) s += ",\\\n".join([str(f['xainvs']) for f in res]) s += ']' + eol + '\n' strIO = StringIO.StringIO() strIO.write(s) strIO.seek(0) return send_file(strIO, attachment_filename=filename, as_attachment=True, add_etags=False)
def random_curve(): label = random_object_from_collection( db_ec() )['lmfdb_label'] cond, iso, num = split_lmfdb_label(label) return redirect(url_for(".by_triple_label", conductor=cond, iso_label=iso, number=num))
def elliptic_curve_search(info): if info.get('download') == '1' and info.get('Submit') and info.get('query'): return download_search(info) if 'SearchAgain' in info: return rational_elliptic_curves() query = {} bread = info.get('bread',[('Elliptic Curves', url_for("ecnf.index")), ('$\Q$', url_for(".rational_elliptic_curves")), ('Search Results', '.')]) if 'jump' in info: label = info.get('label', '').replace(" ", "") m = match_lmfdb_label(label) if m: try: return by_ec_label(label) except ValueError: return elliptic_curve_jump_error(label, info, wellformed_label=True) elif label.startswith("Cremona:"): label = label[8:] m = match_cremona_label(label) if m: try: return by_ec_label(label) except ValueError: return elliptic_curve_jump_error(label, info, wellformed_label=True) elif match_cremona_label(label): return elliptic_curve_jump_error(label, info, cremona_label=True) elif label: # Try to parse a string like [1,0,3,2,4] as valid # Weistrass coefficients: lab = re.sub(r'\s','',label) lab = re.sub(r'^\[','',lab) lab = re.sub(r']$','',lab) try: labvec = lab.split(',') labvec = [QQ(str(z)) for z in labvec] # Rationals allowed E = EllipticCurve(labvec) # Now we do have a valid curve over Q, but it might # not be in the database. ainvs = [str(c) for c in E.minimal_model().ainvs()] xainvs = ''.join(['[',','.join(ainvs),']']) data = db_ec().find_one({'xainvs': xainvs}) if data is None: data = db_ec().find_one({'ainvs': ainvs}) if data is None: info['conductor'] = E.conductor() return elliptic_curve_jump_error(label, info, missing_curve=True) return by_ec_label(data['lmfdb_label']) except (TypeError, ValueError, ArithmeticError): return elliptic_curve_jump_error(label, info) else: query['label'] = '' try: parse_rational(info,query,'jinv','j-invariant') parse_ints(info,query,'conductor') parse_ints(info,query,'torsion','torsion order') parse_ints(info,query,'rank') parse_ints(info,query,'sha','analytic order of Ш') parse_bracketed_posints(info,query,'torsion_structure',maxlength=2,process=str,check_divisibility='increasing') # speed up slow torsion_structure searches by also setting torsion if 'torsion_structure' in query and not 'torsion' in query: query['torsion'] = reduce(mul,[int(n) for n in query['torsion_structure']],1) if 'include_cm' in info: if info['include_cm'] == 'exclude': query['cm'] = 0 elif info['include_cm'] == 'only': query['cm'] = {'$ne' : 0} parse_ints(info,query,field='isodeg',qfield='isogeny_degrees') parse_primes(info, query, 'surj_primes', name='surjective primes', qfield='non-maximal_primes', mode='complement') if info.get('surj_quantifier') == 'exactly': mode = 'exact' else: mode = 'append' parse_primes(info, query, 'nonsurj_primes', name='non-surjective primes', qfield='non-maximal_primes',mode=mode) except ValueError as err: info['err'] = str(err) return search_input_error(info, bread) count = parse_count(info,100) start = parse_start(info) if 'optimal' in info and info['optimal'] == 'on': # fails on 990h3 query['number'] = 1 info['query'] = query cursor = db_ec().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('conductor', ASCENDING), ('iso_nlabel', ASCENDING), ('lmfdb_number', ASCENDING)]).skip(start).limit(count) info['curves'] = res info['format_ainvs'] = format_ainvs info['curve_url'] = lambda dbc: url_for(".by_triple_label", conductor=dbc['conductor'], iso_label=split_lmfdb_label(dbc['lmfdb_iso'])[1], number=dbc['lmfdb_number']) info['iso_url'] = lambda dbc: url_for(".by_double_iso_label", conductor=dbc['conductor'], iso_label=split_lmfdb_label(dbc['lmfdb_iso'])[1]) info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) if nres == 1: info['report'] = 'unique match' elif nres == 2: info['report'] = 'displaying both matches' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres #credit = 'John Cremona' #if 'non-surjective_primes' in query or 'non-maximal_primes' in query: # credit += ' and Andrew Sutherland' t = info.get('title','Elliptic Curves search results') return render_template("ec-search-results.html", info=info, credit=ec_credit(), bread=bread, title=t)
def isogeny_class_cm(label): return db_ec().find_one({'lmfdb_iso': label}, { '_id': False, 'cm': True })['cm']
def make_class(self): self.CM = self.cm N, iso, number = split_lmfdb_label(self.lmfdb_iso) # Extract the size of the isogeny class from the database ncurves = self.class_size # Create a list of the curves in the class from the database self.curves = [db_ec().find_one({'iso':self.iso, 'lmfdb_number': i+1}) for i in range(ncurves)] # Set optimality flags. The optimal curve is number 1 except # in one case which is labeled differently in the Cremona tables for c in self.curves: c['optimal'] = (c['number']==(3 if self.label == '990h' else 1)) c['ai'] = parse_ainvs(c['xainvs']) c['url'] = url_for(".by_triple_label", conductor=N, iso_label=iso, number=c['lmfdb_number']) from sage.matrix.all import Matrix self.isogeny_matrix = Matrix(self.isogeny_matrix) self.isogeny_matrix_str = latex(matrix(self.isogeny_matrix)) # Create isogeny graph: self.graph = make_graph(self.isogeny_matrix) P = self.graph.plot(edge_labels=True) self.graph_img = encode_plot(P) self.graph_link = '<img src="%s" width="200" height="150"/>' % self.graph_img self.newform = web_latex(PowerSeriesRing(QQ, 'q')(self.anlist, 20, check=True)) self.newform_label = newform_label(N,2,1,iso) self.newform_link = url_for("emf.render_elliptic_modular_forms", level=N, weight=2, character=1, label=iso) self.newform_exists_in_db = is_newform_in_db(self.newform_label) self.lfunction_link = url_for("l_functions.l_function_ec_page", conductor_label = N, isogeny_class_label = iso) self.friends = [('L-function', self.lfunction_link)] if not self.CM: self.CM = "no" if int(N)<=300: self.friends += [('Symmetric square L-function', url_for("l_functions.l_function_ec_sym_page", power='2', conductor = N, isogeny = iso))] if int(N)<=50: self.friends += [('Symmetric cube L-function', url_for("l_functions.l_function_ec_sym_page", power='3', conductor = N, isogeny = iso))] if self.newform_exists_in_db: self.friends += [('Modular form ' + self.newform_label, self.newform_link)] self.properties = [('Label', self.lmfdb_iso), ('Number of curves', str(ncurves)), ('Conductor', '\(%s\)' % N), ('CM', '%s' % self.CM), ('Rank', '\(%s\)' % self.rank), ('Graph', ''),(None, self.graph_link) ] self.downloads = [('Download coefficients of newform', url_for(".download_EC_qexp", label=self.lmfdb_iso, limit=1000)), ('Download stored data for all curves', url_for(".download_EC_all", label=self.lmfdb_iso))] if self.lmfdb_iso == self.iso: self.title = "Elliptic Curve Isogeny Class %s" % self.lmfdb_iso else: self.title = "Elliptic Curve Isogeny Class %s (Cremona label %s)" % (self.lmfdb_iso, self.iso) self.bread = [('Elliptic Curves', url_for("ecnf.index")), ('$\Q$', url_for(".rational_elliptic_curves")), ('%s' % N, url_for(".by_conductor", conductor=N)), ('%s' % iso, ' ')] self.code = {} self.code['show'] = {'sage':''} # use default show names self.code['class'] = {'sage':'E = EllipticCurve("%s1")\n'%(self.lmfdb_iso) + 'E.isogeny_class()\n'} self.code['curves'] = {'sage':'E.isogeny_class().curves'} self.code['rank'] = {'sage':'E.rank()'} self.code['q_eigenform'] = {'sage':'E.q_eigenform(10)'} self.code['matrix'] = {'sage':'E.isogeny_class().matrix()'} self.code['plot'] = {'sage':'E.isogeny_graph().plot(edge_labels=True)'}
def nr_of_EC_in_isogeny_class(label): ''' Returns the number of elliptic curves in the isogeny class with given label. ''' return db_ec().find({'lmfdb_iso':label}).count()
def nr_of_EC_in_isogeny_class(label): ''' Returns the number of elliptic curves in the isogeny class with given label. ''' return db_ec().find({'lmfdb_iso': label}).count()
def isogeny_class_cm(label): return db_ec().find_one({'lmfdb_iso':label},{'_id':False,'cm':True})['cm']
def __init__(self): logger.debug("Constructing an instance of ECstats") self.ecdb = db_ec() self._counts = {} self._stats = {}
def elliptic_curve_search(info): if info.get('download') == '1' and info.get('Submit') and info.get('query'): return download_search(info) if 'SearchAgain' in info: return rational_elliptic_curves() query = {} bread = info.get('bread',[('Elliptic Curves', url_for("ecnf.index")), ('$\Q$', url_for(".rational_elliptic_curves")), ('Search Results', '.')]) if 'jump' in info: label = info.get('label', '').replace(" ", "") m = match_lmfdb_label(label) if m: try: return by_ec_label(label) except ValueError: return elliptic_curve_jump_error(label, info, wellformed_label=True) elif label.startswith("Cremona:"): label = label[8:] m = match_cremona_label(label) if m: try: return by_ec_label(label) except ValueError: return elliptic_curve_jump_error(label, info, wellformed_label=True) elif match_cremona_label(label): return elliptic_curve_jump_error(label, info, cremona_label=True) elif label: # Try to parse a string like [1,0,3,2,4] as valid # Weistrass coefficients: lab = re.sub(r'\s','',label) lab = re.sub(r'^\[','',lab) lab = re.sub(r']$','',lab) try: labvec = lab.split(',') labvec = [QQ(str(z)) for z in labvec] # Rationals allowed E = EllipticCurve(labvec) # Now we do have a valid curve over Q, but it might # not be in the database. ainvs = [str(c) for c in E.minimal_model().ainvs()] xainvs = ''.join(['[',','.join(ainvs),']']) data = db_ec().find_one({'xainvs': xainvs}) if data is None: data = db_ec().find_one({'ainvs': ainvs}) if data is None: info['conductor'] = E.conductor() return elliptic_curve_jump_error(label, info, missing_curve=True) return by_ec_label(data['lmfdb_label']) except (TypeError, ValueError, ArithmeticError): return elliptic_curve_jump_error(label, info) else: query['label'] = '' try: parse_rational(info,query,'jinv','j-invariant') parse_ints(info,query,'conductor') parse_ints(info,query,'torsion','torsion order') parse_ints(info,query,'rank') parse_ints(info,query,'sha','analytic order of Ш') parse_bracketed_posints(info,query,'torsion_structure',maxlength=2,process=str,check_divisibility='increasing') # speed up slow torsion_structure searches by also setting torsion if 'torsion_structure' in query and not 'torsion' in query: query['torsion'] = reduce(mul,[int(n) for n in query['torsion_structure']],1) if 'include_cm' in info: if info['include_cm'] == 'exclude': query['cm'] = 0 elif info['include_cm'] == 'only': query['cm'] = {'$ne' : 0} parse_ints(info,query,field='isodeg',qfield='isogeny_degrees') parse_primes(info, query, 'surj_primes', name='surjective primes', qfield='non-maximal_primes', mode='complement') if info.get('surj_quantifier') == 'exactly': mode = 'exact' else: mode = 'append' parse_primes(info, query, 'nonsurj_primes', name='non-surjective primes', qfield='non-maximal_primes',mode=mode) except ValueError as err: info['err'] = str(err) return search_input_error(info, bread) count = parse_count(info,100) start = parse_start(info) if 'optimal' in info and info['optimal'] == 'on': # fails on 990h3 query['number'] = 1 info['query'] = query cursor = db_ec().find(query) nres = cursor.count() if(start >= nres): start -= (1 + (start - nres) / count) * count if(start < 0): start = 0 res = cursor.sort([('conductor', ASCENDING), ('iso_nlabel', ASCENDING), ('lmfdb_number', ASCENDING)]).skip(start).limit(count) info['curves'] = res info['format_ainvs'] = format_ainvs info['curve_url'] = lambda dbc: url_for(".by_triple_label", conductor=dbc['conductor'], iso_label=split_lmfdb_label(dbc['lmfdb_iso'])[1], number=dbc['lmfdb_number']) info['iso_url'] = lambda dbc: url_for(".by_double_iso_label", conductor=dbc['conductor'], iso_label=split_lmfdb_label(dbc['lmfdb_iso'])[1]) info['number'] = nres info['start'] = start info['count'] = count info['more'] = int(start + count < nres) if nres == 1: info['report'] = 'unique match' elif nres == 2: info['report'] = 'displaying both matches' else: if nres > count or start != 0: info['report'] = 'displaying matches %s-%s of %s' % (start + 1, min(nres, start + count), nres) else: info['report'] = 'displaying all %s matches' % nres credit = 'John Cremona' if 'non-surjective_primes' in query or 'non-maximal_primes' in query: credit += ' and Andrew Sutherland' t = info.get('title','Elliptic Curves search results') return render_template("ec-search-results.html", info=info, credit=credit, bread=bread, title=t)
def getEllipticCurveData(label): from lmfdb.elliptic_curves.web_ec import db_ec return db_ec().find_one({'lmfdb_label': label})