Пример #1
0
 def by_label(label):
     """
     Searches for a specific genus 2 curve or isogeny class in the curves collection by its label.
     It label is an isogeny class label, constructs an object for an arbitrarily chosen curve in the isogeny class
     Constructs the WebG2C object if the curve is found, raises an error otherwise
     """
     try:
         slabel = label.split(".")
         if len(slabel) == 2:
             curve = g2c_db_curves().find_one({"class": label})
         elif len(slabel) == 4:
             curve = g2c_db_curves().find_one({"label": label})
         else:
             raise ValueError("Invalid genus 2 label %s." % label)
     except AttributeError:
         raise ValueError("Invalid genus 2 label %s." % label)
     if not curve:
         if len(slabel) == 2:
             raise KeyError(
                 "Genus 2 isogeny class %s not found in the database." %
                 label)
         else:
             raise KeyError("Genus 2 curve %s not found in database." %
                            label)
     endo = g2c_db_endomorphisms().find_one({"label": curve['label']})
     if not endo:
         g2c_logger.error(
             "Endomorphism data for genus 2 curve %s not found in database."
             % label)
         raise KeyError(
             "Endomorphism data for genus 2 curve %s not found in database."
             % label)
     return WebG2C(curve, endo, is_curve=(len(slabel) == 4))
Пример #2
0
 def by_label(label):
     """
     Searches for a specific genus 2 curve or isogeny class in the curves collection by its label.
     It label is an isogeny class label, constructs an object for an arbitrarily chosen curve in the isogeny class
     Constructs the WebG2C object if the curve is found, raises an error otherwise
     """
     try:
         slabel = label.split(".")
         if len(slabel) == 2:
             curve = g2c_db_curves().find_one({"class" : label})
         elif len(slabel) == 4:
             curve = g2c_db_curves().find_one({"label" : label})
         else:
             raise ValueError("Invalid genus 2 label %s." % label)
     except AttributeError:
         raise ValueError("Invalid genus 2 label %s." % label)
     if not curve:
         if len(slabel) == 2:
             raise KeyError("Genus 2 isogeny class %s not found in the database." % label)
         else:
             raise KeyError("Genus 2 curve %s not found in database." % label)
     endo = g2c_db_endomorphisms().find_one({"label" : curve['label']})
     if not endo:
         g2c_logger.error("Endomorphism data for genus 2 curve %s not found in database." % label)
         raise KeyError("Endomorphism data for genus 2 curve %s not found in database." % label)
     tama = g2c_db_tamagawa_numbers().find({"label" : curve['label']}).sort('p', ASCENDING)
     if tama.count() == 0:
         g2c_logger.error("Tamagawa number data for genus 2 curve %s not found in database." % label)
         raise KeyError("Tamagawa number data for genus 2 curve %s not found in database." % label)        
     return WebG2C(curve, endo, tama, is_curve=(len(slabel)==4))
Пример #3
0
 def by_label(label):
     """
     Searches for a specific genus 2 curve or isogeny class in the curves collection by its label.
     It label is an isogeny class label, constructs an object for an arbitrarily chosen curve in the isogeny class
     Constructs the WebG2C object if the curve is found, raises an error otherwise
     """
     try:
         slabel = label.split(".")
         if len(slabel) == 2:
             curve = g2c_db_curves().find_one({"class": label})
         elif len(slabel) == 4:
             curve = g2c_db_curves().find_one({"label": label})
         else:
             raise ValueError("Invalid genus 2 label %s." % label)
     except AttributeError:
         raise ValueError("Invalid genus 2 label %s." % label)
     if not curve:
         if len(slabel) == 2:
             raise KeyError(
                 "Genus 2 isogeny class %s not found in the database." %
                 label)
         else:
             raise KeyError("Genus 2 curve %s not found in database." %
                            label)
     endo = g2c_db_endomorphisms().find_one({"label": curve['label']})
     if not endo:
         g2c_logger.error(
             "Endomorphism data for genus 2 curve %s not found in database."
             % label)
         raise KeyError(
             "Endomorphism data for genus 2 curve %s not found in database."
             % label)
     tama = g2c_db_tamagawa_numbers().find({
         "label": curve['label']
     }).sort('p', ASCENDING)
     if tama.count() == 0:
         g2c_logger.error(
             "Tamagawa number data for genus 2 curve %s not found in database."
             % label)
         raise KeyError(
             "Tamagawa number data for genus 2 curve %s not found in database."
             % label)
     if len(slabel) == 4:
         ratpts = g2c_db_rational_points().find_one(
             {"label": curve['label']})
         if not ratpts:
             g2c_logger.warning(
                 "No rational points data for genus 2 curve %s found in database."
                 % label)
     else:
         ratpts = {}
     return WebG2C(curve, endo, tama, ratpts, is_curve=(len(slabel) == 4))
Пример #4
0
 def by_label(label):
     """
     Searches for a specific genus 2 curve or isogeny class in the curves collection by its label.
     It label is an isogeny class label, constructs an object for an arbitrarily chosen curve in the isogeny class
     Constructs the WebG2C object if the curve is found, raises an error otherwise
     """
     try:
         slabel = label.split(".")
         if len(slabel) == 2:
             curve = db.g2c_curves.lucky({"class" : label})
         elif len(slabel) == 4:
             curve = db.g2c_curves.lookup(label)
         else:
             raise ValueError("Invalid genus 2 label %s." % label)
     except AttributeError:
         raise ValueError("Invalid genus 2 label %s." % label)
     if not curve:
         if len(slabel) == 2:
             raise KeyError("Genus 2 isogeny class %s not found in the database." % label)
         else:
             raise KeyError("Genus 2 curve %s not found in database." % label)
     endo = db.g2c_endomorphisms.lookup(curve['label'])
     if not endo:
         g2c_logger.error("Endomorphism data for genus 2 curve %s not found in database." % label)
         raise KeyError("Endomorphism data for genus 2 curve %s not found in database." % label)
     tama = list(db.g2c_tamagawa.search({"label": curve['label']}))
     if len(tama) == 0:
         g2c_logger.error("Tamagawa number data for genus 2 curve %s not found in database." % label)
         raise KeyError("Tamagawa number data for genus 2 curve %s not found in database." % label)
     if len(slabel)==4:
         ratpts = db.g2c_ratpts.lookup(curve['label'])
         if not ratpts:
             g2c_logger.warning("No rational points data for genus 2 curve %s found in database." % label)
     else:
         ratpts = {}
     return WebG2C(curve, endo, tama, ratpts, is_curve=(len(slabel)==4))
Пример #5
0
 def by_label(label):
     """
     Searches for a specific genus 2 curve or isogeny class in the curves collection by its label.
     It label is an isogeny class label, constructs an object for an arbitrarily chosen curve in the isogeny class
     Constructs the WebG2C object if the curve is found, raises an error otherwise
     """
     try:
         slabel = label.split(".")
         if len(slabel) == 2:
             curve = db.g2c_curves.lucky({"class" : label})
         elif len(slabel) == 4:
             curve = db.g2c_curves.lookup(label)
         else:
             raise ValueError("Invalid genus 2 label %s." % label)
     except AttributeError:
         raise ValueError("Invalid genus 2 label %s." % label)
     if not curve:
         if len(slabel) == 2:
             raise KeyError("Genus 2 isogeny class %s not found in the database." % label)
         else:
             raise KeyError("Genus 2 curve %s not found in database." % label)
     endo = db.g2c_endomorphisms.lookup(curve['label'])
     if not endo:
         g2c_logger.error("Endomorphism data for genus 2 curve %s not found in database." % label)
         raise KeyError("Endomorphism data for genus 2 curve %s not found in database." % label)
     tama = list(db.g2c_tamagawa.search({"label": curve['label']}))
     if len(tama) == 0:
         g2c_logger.error("Tamagawa number data for genus 2 curve %s not found in database." % label)
         raise KeyError("Tamagawa number data for genus 2 curve %s not found in database." % label)
     if len(slabel)==4:
         ratpts = db.g2c_ratpts.lookup(curve['label'])
         if not ratpts:
             g2c_logger.warning("No rational points data for genus 2 curve %s found in database." % label)
     else:
         ratpts = {}
     clus = []
     for x in tama:
         if x['p'] != 2:
             try:
                 clusentry = db.cluster_pictures.lucky({"label": x['cluster_label']})
                 #clusimg = clusentry['image']
                 clusthmb = clusentry['thumbnail']
                 clus.append([x['p'], x['cluster_label'], clusthmb])
             except Exception:
                 g2c_logger.error("Cluster picture data for genus 2 curve %s not found in database." % label)
                 raise KeyError("Cluster picture data for genus 2 curve %s not found in database." % label)
     return WebG2C(curve, endo, tama, ratpts, clus, is_curve=(len(slabel)==4))