Ticket #11115: trac_11115_reviewer.patch

File trac_11115_reviewer.patch, 6.3 KB (added by vbraun, 3 years ago)

Reviewer patch

  • sage/misc/cachefunc.pyx

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1317075226 -7200
    # Node ID 586b3e95fe15f83dcab64854f5300c4edaad921e
    # Parent  18829af747d0b29525feb685cfd9fb611eca466b
    Trac #11115: Reviewer patch
    
    Just removed out-of-date commented-out code and typos in docstrings.
    
    diff --git a/sage/misc/cachefunc.pyx b/sage/misc/cachefunc.pyx
    a b  
    181181    sage: e.element_via_parent_test() is e.element_via_parent_test() 
    182182    True 
    183183 
    184 The other element class can only inherit a `cached_in_parent_method`, since 
     184The other element class can only inherit a ``cached_in_parent_method``, since 
    185185the cache is stored in the parent. In fact, equal elements share the cache, 
    186186even if they are of different types:: 
    187187 
     
    235235 
    236236It is a very common special case to cache a method that has no 
    237237arguments. In that special case, the time needed to access the cache 
    238 can be drastically reduced by using a special implmentation. The 
     238can be drastically reduced by using a special implementation. The 
    239239cached method decorator automatically determines which implementation 
    240240ought to be chosen. A typical example is 
    241241:meth:`sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal.gens` 
     
    738738        sage: R.<x, y, z> = PolynomialRing(QQ, 3) 
    739739        sage: I = R*(x^3 + y^3 + z^3,x^4-y^4) 
    740740        sage: I.groebner_basis() 
    741         [y^5*z^3 - 1/4*x^2*z^6 + 1/2*x*y*z^6 + 1/4*y^2*z^6, x^2*y*z^3 - x*y^2*z^3 + 2*y^3*z^3 + z^6, x*y^3 + y^4 + x*z^3, x^3 + y^3 + z^3] 
     741        [y^5*z^3 - 1/4*x^2*z^6 + 1/2*x*y*z^6 + 1/4*y^2*z^6,  
     742         x^2*y*z^3 - x*y^2*z^3 + 2*y^3*z^3 + z^6, 
     743         x*y^3 + y^4 + x*z^3, x^3 + y^3 + z^3] 
    742744        sage: I.groebner_basis 
    743745        Cached version of <function groebner_basis at 0x...> 
    744746 
     
    15841586 
    15851587    The example shows that the actual computation 
    15861588    takes place only once, and that the result is 
    1587     identic for equivalent input:: 
     1589    identical for equivalent input:: 
    15881590    
    15891591        sage: res = a.f(3, 2); res 
    15901592        computing 
  • sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py

    diff --git a/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py
    a b  
    579579        if E!=self: 
    580580            self._Cartier_matrix_cached.clear_cache() 
    581581            M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() 
    582 #        A=self._Cartier_matrix_cached.get_cache() 
    583 #        if len(A) !=0: 
    584 #            if A.items()[-1][-1][-1]==self: 
    585 #                M,Coeffs,g, Fq, p,E = A.items()[-1][1]; 
    586 #            else: 
    587 #                A.clear() 
    588 #                M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() 
    589 #        else: 
    590 #            A.clear() 
    591 #            M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() 
    592582        return M 
    593583             
    594584    #This where Hasse_Witt is actually computed. This is either called by E.Hasse_Witt or p_rank 
     
    665655            self._Cartier_matrix_cached.clear_cache() 
    666656            M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() 
    667657 
    668 #        A=self._Cartier_matrix_cached.get_cache() 
    669 #        if len(A) !=0: 
    670 #            if A.items()[-1][-1][-1]==self: 
    671 #                M,Coeffs,g, Fq, p,E = A.items()[-1][1]; 
    672 #            else: 
    673 #                A.clear() 
    674 #                M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() 
    675 #        else: 
    676 #            A.clear() 
    677 #            M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() 
    678          
    679658        #This compute the action of p^kth Frobenius  on list of coefficients        
    680659        def frob_mat(Coeffs, k): 
    681660            a = p**k 
     
    686665                mat.append(H); 
    687666            return matrix(Fq,mat) 
    688667     
    689          
    690      
    691668        #Computes all the different possible action of frobenius on matrix M and stores in list Mall        
    692669        Mall = [M] + [frob_mat(Coeffs,k) for k in range(1,g)] 
    693670         
     
    759736            self._Hasse_Witt_cached.clear_cache() 
    760737            N, E= self._Hasse_Witt_cached() 
    761738        return N 
    762 #        A=self._Hasse_Witt_cached.get_cache() 
    763 #        if len(A) !=0: 
    764 #            if A.items()[-1][-1][-1]==self: 
    765 #                N, E = A.items()[-1][1]; 
    766 #            else: 
    767 #                A.clear() 
    768 #                N, E= self._Hasse_Witt_cached() 
    769 #        else: 
    770 #            A.clear() 
    771 #            N, E= self._Hasse_Witt_cached() 
    772 #        return N 
    773739 
    774740    def a_number(self): 
    775741        r""" 
     
    810776        # Since Trac Ticket #11115, there is a special cache for methods 
    811777        # that don't accept arguments. The easiest is: Call the cached 
    812778        # method, and test whether the last entry is self. 
    813  
    814 #        A=self._Cartier_matrix_cached.get_cache() 
    815 #        if len(A) !=0: 
    816 #            if A.items()[-1][-1][-1]==self: 
    817 #                M,Coeffs,g, Fq, p,E = A.items()[-1][1]; 
    818 #            else: 
    819 #                A.clear() 
    820 #                M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() 
    821 #        else: 
    822 #            A.clear() 
    823 #            M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() 
    824779        M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() 
    825780        if E != self: 
    826781            self._Cartier_matrix_cached.clear_cache() 
     
    855810            sage: E=HyperellipticCurve(x^29+1,0) 
    856811            sage: E.p_rank() 
    857812            0 
    858  
    859  
    860  
    861        
    862813        """ 
    863814        #We use caching here since Hasse Witt is needed to compute p_rank. So if the Hasse Witt  
    864815        #is already computed it is stored in list A. If it was not cached (i.e. A is empty), we simply 
     
    867818        #the last entry in A. If it does not match, clear A and compute Hasse Witt. 
    868819        # However, it seems a waste of time to manually analyse the cache 
    869820        # -- See Trac Ticket #11115 
    870  
    871821        N,E= self._Hasse_Witt_cached() 
    872822        if E!=self: 
    873823            self._Hasse_Witt_cached.clear_cache() 
    874824            N,E= self._Hasse_Witt_cached() 
    875 #        A=self._Hasse_Witt_cached.get_cache() 
    876 #        if len(A) !=0: 
    877 #            if A.items()[-1][-1][-1]==self: 
    878 #                N,E = A.items()[-1][1]; 
    879 #            else: 
    880 #                A.clear() 
    881 #                N,E= self._Hasse_Witt_cached() 
    882 #        else: 
    883 #            A.clear() 
    884 #            N,E= self._Hasse_Witt_cached() 
    885825        pr=rank(N); 
    886826        return pr 
    887827