Ticket #4755: trac_4755.patch

File trac_4755.patch, 4.8 KB (added by AlexGhitza, 14 years ago)
  • sage/databases/cremona.py

    # HG changeset patch
    # User Alexandru Ghitza <aghitza@alum.mit.edu>
    # Date 1232702207 -39600
    # Node ID 03f5acb29102bd606136e82775dbc72037a6847f
    # Parent  f8fb0bf3e547d65a0f90f5b27d543c8cf4ca9da0
    trac 4755: fixes in interfacing with Cremona database
    
    diff -r f8fb0bf3e547 -r 03f5acb29102 sage/databases/cremona.py
    a b  
    55easy-to-use format.  The unique instance of the class
    66CremonaDatabase() gives access to the database.
    77
    8 If the full CremonaDatabase isn't installed, a mini-version, which is
    9 included by default with SAGE, is included.  It includes Weierstrass
     8If the full CremonaDatabase isn't installed, a mini-version is
     9included by default with SAGE.  It contains Weierstrass
    1010equations, rank, and torsion for curves up to conductor 10000.
    1111
    1212The large database includes all curves of conductor up to 120,000 (!).
     
    145145
    146146def old_cremona_letter_code(n):
    147147    r"""
    148     Returns \emph{old} the Cremona letter code corresponding to an
     148    Returns the \emph{old} Cremona letter code corresponding to an
    149149    integer.
    150150
    151151    For example,
     
    209209
    210210def parse_cremona_label(label):
    211211    """
    212     Given a Cremona label corresponding that defines an elliptic
     212    Given a Cremona label that defines an elliptic
    213213    curve, e.g., 11A1 or 37B3, parse the label and return the
    214214    conductor, isogeny class label, and number.
    215215
    216     The isogeny number may be omitted, in which case it default to 1.
     216    The isogeny number may be omitted, in which case it defaults to 1.
    217217    If the isogeny number and letter are both omitted, so label is
    218218    just a string representing a conductor, then the label defaults to
    219219    'A' and the number to 1.
     
    548548    def isogeny_class(self, label):
    549549        """
    550550        Returns the isogeny class of elliptic curves that are
    551         isogeneous to the curve with given Cremona label.
     551        isogenous to the curve with given Cremona label.
    552552        INPUT:
    553553            label -- string
    554554        OUTPUT:
    555             list -- list of EllpticCurve objects.
     555            list -- list of EllipticCurve objects.
    556556        """
    557557        conductor, iso, num = parse_cremona_label(label)
    558558        A = self.allcurves(conductor)
     
    583583        INPUT:
    584584            conductors -- list or generator of ints
    585585        OUTPUT:
    586             generator that iterates over EllipticCurve objects.
     586            list of EllipticCurve objects.
    587587        """
    588588        return list(self.iter(conductors))
    589589       
    590     def list(self, conductors):
     590    def list_optimal(self, conductors):
    591591        """
    592592        Returns a list of all optimal curves with conductor between Nmin and
    593593        Nmax-1, inclusive, in the database.
     
    677677            4
    678678            sage: c.number_of_curves(990)
    679679            42
     680            sage: num = c.number_of_curves()
    680681        """
    681682        if N == 0:
    682             return self['number_of_curves']
     683            try:
     684                # if the optional database is installed, the number is
     685                # easy to get
     686                return self['number_of_curves']
     687            except KeyError:
     688                # otherwise we need to do a bit of work
     689                num = 0
     690                for N in range(self.smallest_conductor(), self.largest_conductor()+1):
     691                    L = self.allcurves(N)
     692                    num = num + len(L)
     693                return num
     694           
    683695        C = self.allcurves(N)
    684696        if i == 0:
    685697            return len(C)
     
    690702    def number_of_isogeny_classes(self, N=0):
    691703        """
    692704        Returns the number of isogeny classes of curves in the database
    693         of conductor N.  If N is 0, return the total number of curves
    694         in the database.
     705        of conductor N.  If N is 0, return the total number of isogeny
     706        classes of curves in the database.
    695707
    696708        INPUT:
    697709            N -- int
     
    703715            1
    704716            sage: c.number_of_isogeny_classes(37)
    705717            2
     718            sage: num = c.number_of_isogeny_classes()
    706719        """
    707720        if N == 0:
    708             return self['number_of_isogeny_classes']
     721            try:
     722                # if the optional database is installed, the number is
     723                # easy to get
     724                return self['number_of_isogeny_classes']
     725            except KeyError:
     726                # otherwise we need to do a bit of work
     727                num = 0
     728                for N in range(self.smallest_conductor(), self.largest_conductor()+1):
     729                    L = self.curves(N)
     730                    num = num + len(L)
     731                return num
     732
    709733        return len(self.curves(N))
    710734
     735
    711736    def random(self):
    712737        """
    713738        Returns a random curve from the database.