On Mon, Jun 14, 2010 at 3:50 PM, Florent Hivert
<florent.hiv...@univ-rouen.fr> wrote:
>      Hi Jason,
>
>>>     Looking into sage library, I found the following code: file matrix0.pyx
>>>
>>> cdef class Matrix(sage.structure.element.Matrix):
>>>      ...
>>>      def __copy__(self):
>>>          """
>>>      ...
>>>          """
>>>          return self.__copy__()
>>>
>>> what is the intention here ? I hope this code is never executed ? Why not
>>> return an error ?
>>>
>>
>> Generic matrices have their own __copy__ method (overriding this).  I hope
>> the above code isn't ever executed either.
>>
>> Here is the result of executing the method, which gives the expected error:
>>
>> sage: import sage.matrix.matrix0
>> sage:  A = sage.matrix.matrix0.Matrix(MatrixSpace(QQ,2))
>> sage: type(A)
>> <type 'sage.matrix.matrix0.Matrix'>
>> sage: copy(A)
>> ---------------------------------------------------------------------------
>> RuntimeError                              Traceback (most recent call last)
>>
>> /Users/grout/sage-4.4.2-test3/spkg/standard/sagenb-0.8.p3/src/sagenb/<ipython
>> console> in <module>()
>>
>> /Users/grout/sage/local/lib/python/copy.pyc in copy(x)
>>      77     copier = getattr(cls, "__copy__", None)
>>      78     if copier:
>> ---> 79         return copier(x)
>>      80
>>      81     reductor = dispatch_table.get(cls)
>>
>> /Users/grout/sage/local/lib/python2.6/site-packages/sage/matrix/matrix0.so
>> in sage.matrix.matrix0.Matrix.__copy__ (sage/matrix/matrix0.c:2718)()
>>
>> [snip]
>>
>> RuntimeError: maximum recursion depth exceeded while calling a Python object
>> sage:
>>
>> So the doctests for that function are useless for testing that function,
>> obviously.
>
> So this is just a strange way to raise an error ;-) No particular strange
> Cython stuff to allows for inheritance or whatever...

Nope.  You can (and I hope will) *definitely* safely just delete that
whole function.
The matrix_dense.pyx and matrix_sparse.pyx files both define their own __copy__,
and all matrices derive from one or the other.

This is now http://trac.sagemath.org/sage_trac/ticket/9239

William

 -- William

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to