Ticket #1713: SageElement_sage_.patch

File SageElement_sage_.patch, 2.7 KB (added by malb, 12 years ago)
  • sage/crypto/mq/mpolynomialsystem.py

    # HG changeset patch
    # User Martin Albrecht <malb@informatik.uni-bremen.de>
    # Date 1199714286 0
    # Node ID d23b0784f509160ed7763a4d87367f1900687afd
    # Parent  ac71423af0d999b19966a2dfb9d1f05dc6028ff8
    fixed SageElement_sage_ method
    
    diff -r ac71423af0d9 -r d23b0784f509 sage/crypto/mq/mpolynomialsystem.py
    a b class MPolynomialRoundSystem_generic(Sag 
    170170
    171171    def __cmp__(self, other):
    172172        """
    173         The internal dictionaries are compared.
     173        Compare the ring and generators of self and other.
     174
     175        EXAMPLE:
     176            sage: sr = mq.SR(allow_zero_inversions=True)
     177            sage: F,s = sr.polynomial_system()
     178            sage: F == copy(F) # indirect doctest
     179            True
    174180        """
    175         return cmp(self.__dict__, other.__dict__)
     181        return cmp((self._ring, self._gens),(other._ring, other._gens))
    176182       
    177183    def ring(self):
    178184        """
    class MPolynomialSystem_generic(SageObje 
    477483
    478484    def __cmp__(self, other):
    479485        """
    480         The internal dictionaries are compared.
     486        Compare the ring and rounds of self and other.
     487
     488        EXAMPLE:
     489            sage: sr = mq.SR(allow_zero_inversions=True)
     490            sage: F,s = sr.polynomial_system()
     491            sage: F == copy(F) # indirect doctest
     492            True
    481493        """
    482         return cmp(self.__dict__, other.__dict__)
     494        return cmp((self._ring, self._rounds),(other._ring, other._rounds))
    483495
    484496    def ring(self):
    485497        """
  • sage/interfaces/sage0.py

    diff -r ac71423af0d9 -r d23b0784f509 sage/interfaces/sage0.py
    a b class SageElement(ExpectElement): 
    263263        return SageFunction(self, attrname)
    264264
    265265    def _sage_(self):
     266        """
     267        Return local copy of self.
     268
     269        EXAMPLE:
     270            sage: sr = mq.SR(allow_zero_inversions=True)
     271            sage: F,s = sr.polynomial_system()
     272            sage: F == sage0(F)._sage_()
     273            True
     274        """
    266275        P = self.parent()
    267276        if P.is_remote():
    268277            P.eval('save(%s, "%s")'%(self.name(), P._remote_tmpfile()))
    269278            P._get_tmpfile_from_server(self)
    270279            return load(P._local_tmp_file())
    271280        else:
    272             P.eval('dumps(%s, "%s")'%(self.name(), P._local_tmpfile()))
    273             return loads(open(P._local_tmpfile()).read())
     281            P.eval('save(%s, "%s")'%(self.name(), P._local_tmpfile()))
     282            return load(P._local_tmpfile())
    274283   
    275284class SageFunction(FunctionElement):
    276285    def __call__(self, *args):