On Mon, Feb 15, 2010 at 1:35 PM, Florent Hivert
<florent.hiv...@univ-rouen.fr> wrote:
>      Hi William,
>
>> >> Isn't the following a bug ?
>> >>
>> >>   sage: mat = matrix(ZZ, [[1,1],[1,1]], sparse=False)
>> >>   sage: type(mat)
>> >>   <type 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
>> >>   sage: mat2 = matrix(ZZ, mat, sparse=True)
>>
>> I didn't know you could even give a matrix as the input to the matrix
>> constructor.  If you type "matrix?" you'll see that of the many types
>> of input that matrix takes, a matrix itself is definitely not one of
>> them... however the docs specifically say:
>>
>>    "Calling matrix() with a Sage object may return something that makes 
>> sense."
>>
>> That's what's happening here -- your matrix "mat" is just some sage
>> object that has an "_matrix_" method.  It's calling that method on
>> mat.  That method doesn't even take a sparse parameter.
>>
>> So technically the behavior you're seeing agrees with the stated
>> documentation, so isn't a bug.  However, I can see how it could be
>> misleading!   But fixing it could be a can of worms, so... thank you.
>
> My American language is not very good... I'm not sure what you mean by "could
> be a can of worms, so... thank you".

Sorry, that was too idiomatic.  Probably even Americans wouldn't understand.
I meant:

  (1) fixing this right might be surprisingly hard -- it's one of
those issues that one starts working on thinking it will take "5
minutes", but it takes longer than 5 minutes.

  (2) I think it would be wonderful if you do fix it, and I'll greatly
appreciate it.

> Anyway, I'm ok fixing it if it is not too
> complicated. Specifically, I'm ready to put a patch which calls the
> constructor of MatrixSpace as in
>    sage: mat = matrix(ZZ, [[1,1],[1,1]], sparse=False)
>    sage: type(mat)
>    <type 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
>    sage: res = MatrixSpace(ZZ, 2, 2, sparse=True)(mat)
>    sage: type(res)
>    <type 'sage.matrix.matrix_integer_sparse.Matrix_integer_sparse'>
> Is it ok ?
>

Yes.  However, please change the docstring for matrix to also say what
happens when a matrix is passed in.  Currently the docstring says
(indirectly) that _matrix_ will get called, but you'll change that,
for the better.

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