Ticket #111: trac_111.patch

File trac_111.patch, 32.7 KB (added by AlexGhitza, 8 months ago)
  • sage/combinat/matrices/latin.py

    # HG changeset patch
    # User Alexandru Ghitza <aghitza@alum.mit.edu>
    # Date 1247481054 -36000
    # Node ID d1f2723e7fc794d3f08afe7580e985843aee4dd5
    # Parent  ca1f31d6f6bf7b1f8da0cb8973c838ab19921c29
    trac 111: replace .copy() with .__copy__()
    
    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/combinat/matrices/latin.py
    a b  
    131131#***************************************************************************** 
    132132 
    133133import sets 
    134 import copy 
    135134 
    136135from sage.matrix.all import matrix 
    137136from sage.rings.all import ZZ 
     
    318317 
    319318        return self.square == Q.square 
    320319 
    321     def copy(self): 
     320    def __copy__(self): 
    322321        """ 
    323322        To copy a latin square we must copy the underlying matrix. 
    324323         
    325324        EXAMPLES:: 
    326325         
    327326            sage: A = LatinSquare(matrix(ZZ, [[0, 1], [2, 3]])) 
    328             sage: B = A.copy() 
    329             sage: A 
     327            sage: B = copy(A) 
     328            sage: B 
    330329            [0 1] 
    331330            [2 3] 
    332331        """ 
    333  
    334332        C = LatinSquare(self.square.nrows(), self.square.ncols()) 
    335         C.square = self.square.copy() 
     333        from copy import copy 
     334        C.square = copy(self.square) 
    336335        return C 
    337336 
    338337    def clear_cells(self): 
     
    908907 
    909908        n = self.nrows() 
    910909 
    911         G = self.copy() 
     910        from copy import copy 
     911        G = copy(self) 
    912912 
    913913        for r in range(n-1, -1, -1): 
    914914            for c in range(n-1, -1, -1): 
     
    11171117        for x in DLXCPP(dlx_rows): 
    11181118            nr_found += 1 
    11191119 
    1120             Q = copy.deepcopy(self) 
     1120            from copy import deepcopy 
     1121            Q = deepcopy(self) 
    11211122 
    11221123            for y in x: 
    11231124                if len(dlx_rows[y]) == 1: continue # dummy row 
     
    19871988    r1 = r2 = c1 = c2 = x = y = z = -1 
    19881989    proper = True 
    19891990 
    1990     L = L_start.copy() 
     1991    from copy import copy 
     1992    L = copy(L_start) 
    19911993 
    19921994    L_rce = L 
    19931995    L_cer = LatinSquare(n, n) 
     
    26422644    for i in SOLUTIONS.keys(): 
    26432645        soln = list(i) 
    26442646 
    2645         Q = copy.deepcopy(P) 
     2647        from copy import deepcopy 
     2648        Q = deepcopy(P) 
    26462649 
    26472650        for x in soln: 
    26482651            (r, c, e) = cmap[tuple(dlx_rows[x])] 
     
    26882691    assert T1.nrows() == T2.nrows() 
    26892692 
    26902693    n = T1.nrows() 
    2691  
    2692     Q1 = T1.copy() 
    2693     Q2 = T2.copy() 
     2694     
     2695    from copy import copy 
     2696    Q1 = copy(T1) 
     2697    Q2 = copy(T2) 
    26942698 
    26952699    for r in range(n): 
    26962700        for c in range(n): 
  • sage/databases/database.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/databases/database.py
    a b  
    572572        from copy import copy 
    573573        return copy(self.__query_string__) 
    574574         
    575     def copy(self): 
     575    def __copy__(self): 
    576576        """ 
    577577        Returns a copy of the query. 
    578578         
     
    581581            sage: q = 'select graph_id,graph6,num_vertices,num_edges from graph_data where graph_id<=(?) and num_vertices=(?)' 
    582582            sage: param = (22,5) 
    583583            sage: Q = GenericSQLQuery(G,q,param) 
    584             sage: R = Q.copy() 
     584            sage: R = copy(Q) 
    585585            sage: R.get_query_string() 
    586586            'select graph_id,graph6,num_vertices,num_edges from graph_data where graph_id<=(?) and num_vertices=(?)' 
    587587            sage: R.show() 
     
    10001000        else: 
    10011001            self.__query_string__ = '' 
    10021002             
    1003     def copy(self): 
     1003    def __copy__(self): 
    10041004        """ 
    10051005        Returns a copy of itself. 
    10061006         
     
    10321032            55                   E?C_                 6                    
    10331033            210                  F???W                7                    
    10341034            211                  F??G_                7                    
    1035             sage: R = Q.copy() 
     1035            sage: R = copy(Q) 
    10361036            sage: print R 
    10371037            Query for sql database: ...graphs.db 
    10381038            Query string: SELECT graph_data.graph_id, graph_data.graph6, graph_data.num_vertices FROM graph_data WHERE graph_data.num_edges < ? 
     
    11541154                self.__param_tuple__ = self.__param_tuple__ + other.__param_tuple__ 
    11551155 
    11561156        else: 
    1157             if not self.__query_string__: return other.copy() 
    1158             if not other.__query_string__: return self.copy() 
     1157            from copy import copy 
     1158            if not self.__query_string__: return copy(other) 
     1159            if not other.__query_string__: return copy(self) 
    11591160            if join_table is None or join_dict is None: 
    11601161                pattern = ' JOIN ' 
    11611162                if re.search(pattern,self.__query_string__) or re.search(pattern,other.__query_string__): 
     
    11671168                if s[0] != o[0]: 
    11681169                    raise ValueError('Input queries query different tables but join parameters are NoneType') 
    11691170 
    1170             q = self.copy() 
     1171            q = copy(self) 
    11711172             
    11721173            # inner join clause 
    11731174            if join_dict is not None: 
     
    12881289             
    12891290            self.__param_tuple__ = self.__param_tuple__ + other.__param_tuple__ 
    12901291        else: 
    1291             q = self.copy() 
     1292            from copy import copy 
     1293            q = copy(self) 
    12921294            if not self.__query_string__: return q 
    1293             if not other.__query_string__: return other.copy() 
     1295            if not other.__query_string__: return copy(other) 
    12941296            if join_table is None or join_dict is None: 
    12951297                pattern = ' JOIN ' 
    12961298                if re.search(pattern,self.__query_string__) or re.search(pattern,other.__query_string__): 
     
    13551357                self.__query_string__ = re.sub(' WHERE ',' WHERE NOT ( ',self.__query_string__) + ' )' 
    13561358            else: return 
    13571359        else: 
    1358             if not self.__query_string__: return self.copy() 
     1360            if not self.__query_string__:  
     1361                from copy import copy 
     1362                return copy(self) 
    13591363            q = SQLQuery(self.__database__) 
    13601364            q.__query_string__ = re.sub(' WHERE ',' WHERE NOT ( ',self.__query_string__) 
    13611365            q.__query_string__ += ' )' 
     
    15431547                s += '\n' 
    15441548        return s 
    15451549 
    1546     def copy(self): 
     1550    def __copy__(self): 
    15471551        """ 
    15481552        Returns an instance of SQLDatabase that points to a copy database, 
    15491553        and allows modification. 
     
    15521556            sage: DB = SQLDatabase() 
    15531557            sage: DB.create_table('lucy',{'id':{'sql':'INTEGER', 'primary_key':True, 'index':True},'a1':{'sql':'bool','primary_key':False}, 'b2':{'sql':'int', 'primary_key':False}}) 
    15541558            sage: DB.add_rows('lucy', [(0,1,1),(1,1,4),(2,0,7),(3,1,384),(4,1,978932)],['id','a1','b2']) 
    1555             sage: d = DB.copy() 
     1559            sage: d = copy(DB) 
    15561560             
    15571561            sage: d.show('lucy') 
    15581562            a1                   id                   b2                   
     
    15911595            1                    4                    978932 
    15921596 
    15931597        """ 
    1594         from copy import copy 
    15951598        # copy .db file 
    15961599        new_loc = tmp_filename() + '.db' 
    15971600        os.system('cp '+ self.__dblocation__ + ' ' + new_loc) 
  • sage/groups/perm_gps/partn_ref/refinement_python.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/groups/perm_gps/partn_ref/refinement_python.pyx
    a b  
    142142        """ 
    143143        PS_move_min_to_front(self.c_ps, start, end) 
    144144 
    145     def copy(self): 
     145    def __copy__(self): 
    146146        """ 
    147147 
    148148        EXAMPLE:: 
    149149         
    150150            sage: from sage.groups.perm_gps.partn_ref.refinement_python import PythonPartitionStack 
    151151            sage: P = PythonPartitionStack(7) 
    152             sage: Q = P.copy() 
     152            sage: Q = copy(P) 
    153153            sage: P.display() 
    154154            (0 1 2 3 4 5 6) 
    155155            sage: Q.display() 
  • sage/libs/ntl/ntl_ZZX.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/libs/ntl/ntl_ZZX.pyx
    a b  
    149149        cpp_delete_array(val) 
    150150        return result 
    151151 
    152     def copy(self): 
    153         """ 
    154         Return a copy of self. 
    155  
    156         EXAMPLES: 
    157             sage: x = ntl.ZZX([1,32]) 
    158             sage: y = x.copy() 
    159             sage: y == x 
    160             True 
    161             sage: y is x 
    162             False 
    163         """ 
    164         _sig_on 
    165         return self.__copy__() 
    166  
    167152    def __copy__(self): 
    168153        """ 
    169154        Return a copy of self. 
    170155 
    171156        EXAMPLES: 
    172157            sage: x = ntl.ZZX([1,32]) 
    173             sage: y = x.copy() 
     158            sage: y = copy(x) 
    174159            sage: y == x 
    175160            True 
    176161            sage: y is x 
     
    424409        if n < 0: 
    425410            raise NotImplementedError 
    426411        import sage.groups.generic as generic 
    427         return generic.power(self, n, one_ZZX.copy()) 
     412        from copy import copy 
     413        return generic.power(self, n, copy(one_ZZX)) 
    428414 
    429415    def __cmp__(ntl_ZZX self, ntl_ZZX other): 
    430416        """ 
     
    822808            [] 
    823809        """ 
    824810        if m <= 0: 
    825             return zero_ZZX.copy() 
     811            from copy import copy 
     812            return copy(zero_ZZX) 
    826813        _sig_on 
    827814        return make_ZZX(ZZX_truncate(&self.x, m)) 
    828815 
     
    839826            [10 20] 
    840827        """ 
    841828        if m <= 0: 
    842             return zero_ZZX.copy() 
     829            from copy import copy 
     830            return copy(zero_ZZX) 
    843831        return make_ZZX(ZZX_multiply_and_truncate(&self.x, &other.x, m)) 
    844832 
    845833    def square_and_truncate(self, long m): 
     
    854842            [1 4 10 20] 
    855843        """ 
    856844        if m < 0: 
    857             return zero_ZZX.copy() 
     845            from copy import copy 
     846            return copy(zero_ZZX) 
    858847        return make_ZZX(ZZX_square_and_truncate(&self.x, m)) 
    859848 
    860849    def invert_and_truncate(self, long m): 
  • sage/libs/ntl/ntl_ZZ_pEX.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/libs/ntl/ntl_ZZ_pEX.pyx
    a b  
    181181        sage: f = ntl.ZZ_pEX([a, b, b]) 
    182182        sage: f 
    183183        [[3 2] [1 2] [1 2]] 
    184         sage: y = f.copy() 
     184        sage: y = copy(f) 
    185185        sage: y == f 
    186186        True 
    187187        sage: y is f 
     
    194194        r.x = self.x 
    195195        return r 
    196196 
    197     def copy(self): 
    198         """ 
    199         Return a copy of self. 
    200  
    201         EXAMPLES: 
    202         sage: c=ntl.ZZ_pEContext(ntl.ZZ_pX([1,1,1], 7))  
    203         sage: a = ntl.ZZ_pE([3,2], c) 
    204         sage: b = ntl.ZZ_pE([1,2], c) 
    205         sage: f = ntl.ZZ_pEX([a, b, b]) 
    206         sage: f 
    207         [[3 2] [1 2] [1 2]] 
    208         sage: y = f.copy() 
    209         sage: y == f 
    210         True 
    211         sage: y is f 
    212         False 
    213         sage: f[0] = 0; y 
    214         [[3 2] [1 2] [1 2]] 
    215         """ 
    216         return self.__copy__() 
    217          
    218197    def get_modulus_context(self): 
    219198        """ 
    220199        Returns the structure that holds the underlying NTL modulus. 
  • sage/libs/ntl/ntl_ZZ_pX.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/libs/ntl/ntl_ZZ_pX.pyx
    a b  
    173173 
    174174        EXAMPLES: 
    175175            sage: x = ntl.ZZ_pX([0,5,-3],11) 
    176             sage: y = x.copy() 
     176            sage: y = copy(x) 
    177177            sage: x == y 
    178178            True 
    179179            sage: x is y 
     
    186186        r.x = self.x 
    187187        return r 
    188188 
    189     def copy(self): 
    190         """ 
    191         Return a copy of self. 
    192  
    193         EXAMPLES: 
    194             sage: x = ntl.ZZ_pX([0,5,-3],11) 
    195             sage: y = x.copy() 
    196             sage: x == y 
    197             True 
    198             sage: x is y 
    199             False 
    200             sage: x[0] = 4; y 
    201             [0 5 8] 
    202         """ 
    203         return self.__copy__() 
    204          
    205189    def get_modulus_context(self): 
    206190        """ 
    207191        Return the modulus for self. 
  • sage/libs/pari/gen.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/libs/pari/gen.pyx
    a b  
    10481048        """ 
    10491049        return gcmp_sage(left.g, (<gen>right).g) 
    10501050 
    1051     def copy(gen self): 
     1051    def __copy__(gen self): 
    10521052        _sig_on 
    10531053        return P.new_gen(gcopy(self.g)) 
    10541054 
  • sage/modular/modsym/manin_symbols.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modular/modsym/manin_symbols.py
    a b  
    16641664        """ 
    16651665        raise NotImplementedError 
    16661666 
    1667     def copy(self): 
     1667    def __copy__(self): 
    16681668        """ 
    16691669        Return a copy of this ManinSymbol. 
    16701670 
     
    16731673            sage: from sage.modular.modsym.manin_symbols import ManinSymbol, ManinSymbolList_gamma0 
    16741674            sage: m = ManinSymbolList_gamma0(5,8) 
    16751675            sage: s = ManinSymbol(m,(2,2,3)) 
    1676             sage: s2=s.copy() 
     1676            sage: s2 = copy(s) 
    16771677            sage: s2 
    16781678            [X^2*Y^4,(2,3)] 
    16791679         
  • sage/modules/free_module.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modules/free_module.py
    a b  
    116116    sage: A.0[0] = 5 
    117117    Traceback (most recent call last): 
    118118    ... 
    119     ValueError: vector is immutable; please change a copy instead (use self.copy()) 
     119    ValueError: vector is immutable; please change a copy instead (use copy()) 
    120120 
    121121We can save and load submodules and elements:: 
    122122 
     
    59845984        sage: v[0] = 0 # immutable 
    59855985        Traceback (most recent call last): 
    59865986        ... 
    5987         ValueError: vector is immutable; please change a copy instead (use self.copy()) 
     5987        ValueError: vector is immutable; please change a copy instead (use copy()) 
    59885988        sage: sage.modules.free_module.basis_seq(V, V.gens()) 
    59895989        [ 
    59905990        (1, 0), 
  • sage/modules/free_module_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modules/free_module_element.pyx
    a b  
    510510    def _hash(self): 
    511511        return hash(tuple(list(self))) 
    512512 
    513     def copy(self): 
     513    def __copy__(self): 
    514514        """ 
    515515        Make a copy of this vector. 
    516516         
     
    518518         
    519519            sage: v = vector([1..5]); v 
    520520            (1, 2, 3, 4, 5) 
    521             sage: w = v.copy() 
     521            sage: w = copy(v) 
    522522            sage: v == w 
    523523            True 
    524524            sage: v is w 
     
    528528         
    529529            sage: v = vector([1..5], sparse=True); v 
    530530            (1, 2, 3, 4, 5) 
    531             sage: v.copy() 
     531            sage: copy(v) 
    532532            (1, 2, 3, 4, 5) 
    533533        """ 
    534         return self.__copy__() 
    535  
    536     def __copy__(self): 
    537534        if self.is_sparse(): 
    538535            return self.parent()(self.dict()) 
    539536        else: 
     
    552549            sage: v[1] = 10 
    553550            Traceback (most recent call last): 
    554551            ... 
    555             ValueError: vector is immutable; please change a copy instead (use self.copy()) 
     552            ValueError: vector is immutable; please change a copy instead (use copy()) 
    556553        """ 
    557554        self._is_mutable = 0 
    558555 
     
    893890            sage: v[1:2] = [3,5] 
    894891            Traceback (most recent call last): 
    895892            ... 
    896             ValueError: vector is immutable; please change a copy instead (use self.copy()) 
     893            ValueError: vector is immutable; please change a copy instead (use copy()) 
    897894        """ 
    898895        if not self._is_mutable: 
    899             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     896            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    900897        cdef Py_ssize_t k, d, n 
    901898        d = self.degree() 
    902899        R = self.base_ring() 
     
    15331530 
    15341531        if self._degree == 0: 
    15351532            if sparse == self.is_sparse(): 
    1536                 return self.copy() 
     1533                from copy import copy 
     1534                return copy(self) 
    15371535            elif sparse: 
    15381536                return self.sparse_vector() 
    15391537            else: 
     
    15911589        # We would just use apply_map, except that Cython doesn't 
    15921590        # allow lambda functions 
    15931591        if self._degree == 0: 
    1594             return self.copy() 
     1592            from copy import copy 
     1593            return copy(self) 
    15951594 
    15961595        if self.is_sparse(): 
    15971596            v = dict([(i,z.derivative(var)) for i,z in self.dict().items()]) 
     
    18431842        Set entry i of self to value. 
    18441843        """ 
    18451844        if not self._is_mutable: 
    1846             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     1845            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    18471846        i = int(i) 
    18481847        #if not isinstance(i, int): 
    18491848        #    raise TypeError, "index must an integer" 
     
    18691868            (5, 3) 
    18701869        """ 
    18711870        if not self._is_mutable: 
    1872             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     1871            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    18731872        cdef Py_ssize_t k, n, d 
    18741873        d = self.degree() 
    18751874        R = self.base_ring() 
     
    21982197        Like __setitem__ but with no type or bounds checking. 
    21992198        """ 
    22002199        if not self._is_mutable: 
    2201             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     2200            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    22022201        i = int(i) 
    22032202        if x == 0: 
    22042203            if self._entries.has_key(i): 
     
    22252224            TypeError: unable to convert x (=sqrt(2)) to an integer 
    22262225        """ 
    22272226        if not self._is_mutable: 
    2228             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     2227            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    22292228        i = int(i) 
    22302229        #if not isinstance(i, int): 
    22312230        #    raise TypeError, "index must an integer" 
  • sage/modules/vector_double_dense.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modules/vector_double_dense.pyx
    a b  
    133133 
    134134        EXAMPLE: 
    135135            sage: a = vector(RDF, range(9)) 
    136             sage: a == a.copy() 
     136            sage: a == copy(a) 
    137137            True 
    138138        """ 
    139139        if self._degree == 0: 
    140140            return self 
    141         return self._new(self._vector_numpy.copy()) 
     141        from copy import copy 
     142        return self._new(copy(self._vector_numpy)) 
    142143 
    143144    def __init__(self, parent, entries, coerce = True, copy = True): 
    144145        """ 
     
    302303            (0.0, 2.0, 4.0) 
    303304        """ 
    304305        if self._degree == 0: 
    305             return self.copy() 
     306            from copy import copy 
     307            return copy(self) 
    306308         
    307309        cdef Vector_double_dense _right, _left 
    308310        _right = right 
     
    320322            True 
    321323        """ 
    322324        if self._degree == 0: 
    323             return self.copy() 
     325            from copy import copy 
     326            return copy(self) 
    324327 
    325328        cdef Vector_double_dense _right, _left 
    326329        _right = right 
     
    342345        if not right.parent() == self.parent(): 
    343346            right = self.parent().ambient_module()(right) 
    344347        if self._degree == 0: 
    345             return self.copy() 
     348            from copy import copy 
     349            return copy(self) 
    346350 
    347351        cdef Vector_double_dense _right, _left 
    348352        _right = right 
     
    366370            right = self.parent().ambient_module()(right) 
    367371             
    368372        if self._degree == 0: 
    369             return self.copy() 
     373            from copy import copy 
     374            return copy(self) 
    370375         
    371376        cdef Vector_double_dense _right, _left 
    372377        _right = right 
     
    384389            (0, 3.0, 6.0) 
    385390        """ 
    386391        if self._degree == 0: 
    387             return self.copy() 
     392            from copy import copy 
     393            return copy(self) 
    388394 
    389395        return self._new(self._python_dtype(left)*self._vector_numpy) 
    390396 
     
    399405            (0, 3.0, 6.0) 
    400406        """ 
    401407        if self._degree == 0: 
    402             return self.copy() 
     408            from copy import copy 
     409            return copy(self) 
    403410 
    404411        return self._new(self._vector_numpy*self._python_dtype(right)) 
    405412 
     
    505512            sage: v.numpy() 
    506513            array([], dtype=float64) 
    507514        """ 
    508         return self._vector_numpy.copy() 
     515        from copy import copy 
     516        return copy(self._vector_numpy) 
    509517 
    510518    cdef _replace_self_with_numpy(self,cnumpy.ndarray numpy_array): 
    511519        """ 
  • sage/modules/vector_integer_dense.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modules/vector_integer_dense.pyx
    a b  
    144144         
    145145        """ 
    146146        if not self._is_mutable: 
    147             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     147            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    148148        cdef Integer z 
    149149        if i < 0 or i >= self._degree: 
    150150            raise IndexError 
  • sage/modules/vector_rational_dense.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/modules/vector_rational_dense.pyx
    a b  
    145145 
    146146    def __setitem__(self, Py_ssize_t i, x): 
    147147        if not self._is_mutable: 
    148             raise ValueError, "vector is immutable; please change a copy instead (use self.copy())" 
     148            raise ValueError, "vector is immutable; please change a copy instead (use copy())" 
    149149        cdef Rational z 
    150150        if i < 0 or i >= self._degree: 
    151151            raise IndexError 
  • sage/rings/finite_field_element.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/finite_field_element.py
    a b  
    393393            self.__multiplicative_order = order 
    394394            return order 
    395395     
    396     def copy(self): 
     396    def __copy__(self): 
    397397        """ 
    398398        Return a copy of this element. 
    399399         
     
    404404            sage: a = k(5) 
    405405            sage: a 
    406406            2 
    407             sage: a.copy() 
     407            sage: copy(a) 
    408408            2 
    409             sage: b = a.copy() 
     409            sage: b = copy(a) 
    410410            sage: a == b 
    411411            True 
    412412            sage: a is b 
  • sage/rings/fraction_field_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/fraction_field_element.pyx
    a b  
    176176        except NotImplementedError, s: 
    177177            raise ArithmeticError, "unable to reduce because gcd algorithm not implemented on input"             
    178178 
    179     def copy(self): 
     179    def __copy__(self): 
    180180        """ 
    181181        EXAMPLES:: 
    182182         
    183183            sage: R.<x,y> = ZZ[] 
    184184            sage: f = x/y+1; f 
    185185            (x + y)/y 
    186             sage: f.copy() 
     186            sage: copy(f) 
    187187            (x + y)/y 
    188188        """ 
    189189        return self.__class__(self._parent, self.__numerator, 
  • sage/rings/laurent_series_ring_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/laurent_series_ring_element.pyx
    a b  
    940940        """ 
    941941        return self.__u.prec() + self.__n 
    942942 
    943     def copy(self): 
     943    def __copy__(self): 
    944944        return LaurentSeries(self._parent, self.__u.copy(), self.__n) 
    945945 
    946946 
  • sage/rings/padics/padic_ZZ_pX_CA_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_ZZ_pX_CA_element.pyx
    a b  
    15641564        ZZ_to_mpz(&ans.value, &tmp_z) 
    15651565        return ans 
    15661566 
    1567     def copy(self): 
     1567    def __copy__(self): 
    15681568        """ 
    15691569        Returns a copy of ``self``. 
    15701570 
     
    15761576            sage: W.<w> = R.ext(f) 
    15771577            sage: b = W(45, 17); b 
    15781578            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) 
    1579             sage: c = b.copy(); c 
     1579            sage: c = copy(b); c 
    15801580            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) 
    15811581            sage: c is b 
    15821582            False 
  • sage/rings/padics/padic_ZZ_pX_CR_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_ZZ_pX_CR_element.pyx
    a b  
    21902190        # for now, a simple implementation 
    21912191        return self * (~right) 
    21922192 
    2193     def copy(self): 
     2193    def __copy__(self): 
    21942194        """ 
    21952195        Returns a copy of ``self``. 
    21962196 
     
    22022202            sage: W.<w> = R.ext(f) 
    22032203            sage: b = W(45, 17); b 
    22042204            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) 
    2205             sage: c = b.copy(); c 
     2205            sage: c = copy(b); c 
    22062206            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + O(w^17) 
    22072207            sage: c is b 
    22082208            False 
  • sage/rings/padics/padic_ZZ_pX_FM_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_ZZ_pX_FM_element.pyx
    a b  
    837837        ZZ_pX_MulMod_pre(ans.value, self.value, ans.value, self.prime_pow.get_top_modulus()[0]) 
    838838        return ans 
    839839 
    840     def copy(self): 
     840    def __copy__(self): 
    841841        """ 
    842842        Returns a copy of ``self``. 
    843843 
     
    849849            sage: W.<w> = R.ext(f) 
    850850            sage: b = W(45); b 
    851851            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + 2*w^17 + w^19 + 4*w^20 + w^21 + 3*w^22 + 3*w^23 + 4*w^24 + O(w^25) 
    852             sage: c = b.copy(); c 
     852            sage: c = copy(b); c 
    853853            4*w^5 + 3*w^7 + w^9 + w^10 + 2*w^11 + w^12 + w^13 + 3*w^14 + w^16 + 2*w^17 + w^19 + 4*w^20 + w^21 + 3*w^22 + 3*w^23 + 4*w^24 + O(w^25) 
    854854            sage: c is b 
    855855            False 
  • sage/rings/padics/padic_capped_absolute_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_capped_absolute_element.pyx
    a b  
    807807                mpz_mod(ans.value, ans.value, self.prime_pow.pow_mpz_t_tmp(ans.absprec)[0]) 
    808808            return ans 
    809809 
    810     def copy(pAdicCappedAbsoluteElement self): 
     810    def __copy__(pAdicCappedAbsoluteElement self): 
    811811        """ 
    812812        Returns a copy of ``self``. 
    813813 
    814814        EXAMPLES:: 
    815815 
    816             sage: a = ZpCA(5,6)(17); b = a.copy() 
     816            sage: a = ZpCA(5,6)(17); b = copy(a) 
    817817            sage: a == b 
    818818            True 
    819819            sage: a is b 
  • sage/rings/padics/padic_capped_relative_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_capped_relative_element.pyx
    a b  
    14501450            ans._normalized = self._normalized 
    14511451        return ans 
    14521452 
    1453     def copy(self): 
     1453    def __copy__(self): 
    14541454        """ 
    14551455        Returns a copy of self. 
    14561456 
    14571457        EXAMPLES:: 
    14581458 
    1459             sage: a = Zp(5,6)(17); b = a.copy() 
     1459            sage: a = Zp(5,6)(17); b = copy(a) 
    14601460            sage: a == b 
    14611461            True 
    14621462            sage: a is b 
  • sage/rings/padics/padic_fixed_mod_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/padics/padic_fixed_mod_element.pyx
    a b  
    658658        mpz_mod(ans.value, self.value, self.prime_pow.pow_mpz_t_tmp(mpz_get_ui((<Integer>absprec).value))[0]) 
    659659        return ans 
    660660 
    661     def copy(self): 
     661    def __copy__(self): 
    662662        """ 
    663663        Returns a copy of self. 
    664664 
    665665        EXAMPLES:: 
    666666 
    667             sage: a = ZpFM(5,6)(17); b = a.copy() 
     667            sage: a = ZpFM(5,6)(17); b = copy(a) 
    668668            sage: a == b 
    669669            True 
    670670            sage: a is b 
  • sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py
    a b  
    723723            variable = self.parent().variable_name() 
    724724        return pari(self.list()).Polrev(variable) 
    725725 
    726     def copy(self): 
    727         return Polynomial_padic_capped_relative_dense(self.parent(), (self._poly.copy(), self._valbase, copy.copy(self._relprecs), self._normalized, copy.copy(self._valaddeds), copy.copy(self._list)), construct = True) 
     726    def __copy__(self): 
     727        return Polynomial_padic_capped_relative_dense(self.parent(), (copy.copy(self._poly), self._valbase, copy.copy(self._relprecs), self._normalized, copy.copy(self._valaddeds), copy.copy(self._list)), construct = True) 
    728728 
    729729    def degree(self): 
    730730        """ 
  • sage/rings/polynomial/polynomial_element.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/polynomial/polynomial_element.pyx
    a b  
    25022502                f = pari(v).Polrev() 
    25032503                Rpari = R.pari_nf() 
    25042504                if (Rpari.variable() != "a"): 
    2505                     Rpari = Rpari.copy() 
     2505                    Rpari = copy.copy(Rpari) 
    25062506                    Rpari[0] = Rpari[0]("a") 
    25072507                    Rpari[6] = [ x("a") for x in Rpari[6] ] 
    25082508                G = list(Rpari.nffactor(f)) 
  • sage/rings/polynomial/polynomial_element_generic.py

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/polynomial/polynomial_element_generic.py
    a b  
    610610         
    611611        if isinstance(x, Polynomial): 
    612612            if x.parent() == self.parent(): 
    613                 self.__poly = x.__poly.copy() 
     613                from copy import copy 
     614                self.__poly = copy(x.__poly) 
    614615                return 
    615616            else: 
    616617                x = [QQ(a) for a in x.list()] 
     
    868869        Return a copy of this polynomial. 
    869870        """ 
    870871        f = Polynomial_rational_dense(self.parent()) 
    871         f.__poly = self.__poly.copy() 
     872        from copy import copy 
     873        f.__poly = copy(self.__poly) 
    872874        return f 
    873875         
    874876    def degree(self, gen=None): 
  • sage/rings/power_series_poly.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/power_series_poly.pyx
    a b  
    186186 
    187187    def _unsafe_mutate(self, i, value): 
    188188        """ 
    189         SAGE assumes throughout that commutative ring elements are immutable. 
     189        Sage assumes throughout that commutative ring elements are immutable. 
    190190        This is relevant for caching, etc.  But sometimes you need to change 
    191191        a power series and you really know what you're doing.  That's 
    192192        when this function is for you. 
     
    311311 
    312312    def __iter__(self): 
    313313        """ 
    314         Return an interator over the coefficients of this power series. 
     314        Return an iterator over the coefficients of this power series. 
    315315 
    316316        EXAMPLES: 
    317317            sage: R.<t> = QQ[[]] 
     
    572572        return PowerSeries_poly(self._parent, self.__f.truncate(prec), 
    573573                                min(self._prec, prec), check=False) 
    574574         
    575     def copy(self): 
    576         """ 
    577         Return a copy of self. 
    578  
    579         EXAMPLES: 
    580             sage: R.<t> = ZZ[[]] 
    581             sage: f = t + t^3 
    582             sage: f.copy() 
    583             t + t^3 
    584             sage: f.copy() == f 
    585             True 
    586             sage: f.copy() is f 
    587             False 
    588         """ 
    589         return PowerSeries_poly(self._parent, self.__f, self._prec, check=False) 
    590  
    591575    def list(self): 
    592576        """ 
    593577        Return the list of known coefficients for self. This is just 
  • sage/rings/rational.pyx

    diff -r ca1f31d6f6bf -r d1f2723e7fc7 sage/rings/rational.pyx
    a b  
    555555        elif i == 0: return 0 
    556556        else: return 1 
    557557 
    558     def copy(self): 
     558    def __copy__(self): 
    559559        """ 
    560560        Return a copy of self. 
    561561         
     
    564564        EXAMPLES:: 
    565565         
    566566            sage: a = -17/37 
    567             sage: a.copy() is a 
     567            sage: copy(a) is a 
    568568            False 
    569569         
    570570        Coercion does not make a new copy::