The principle of least surprise would suggest that mutability should follow 
the same rules independent of the matrix size. And echelon_form should 
always return an immutable matrix.




On Saturday, August 1, 2015 at 1:51:12 AM UTC+2, Andrey Novoseltsev wrote:
>
> Hello,
>
> While working on http://trac.sagemath.org/ticket/18613 I ran into the 
> following problem:
>
> sage: matrix(2, 1).echelon_form().is_mutable()
> False
> sage: matrix(2, 0).echelon_form().is_mutable()
> True
>
> i.e. while usually echelon_form returns an immutable matrix this is not 
> the case with trivial ones. The reason is in the beginning of its code:
>
>         if self._nrows == 0 or self._ncols == 0:
>             self.cache('pivots', ())
>             self.cache('rank', 0)
>             if transformation:
>                 return self, self
>             return self
>
> The question is how to fix it:
> 1) make here a copy of self, set it to be immutable, and return it
> 2) make self immutable and return self
> 3) always make matrices without elements immutable (not sure if this can 
> be done in one place or in several implementations)
>
> It seems that 3) is the most sensible, but what if some code checks for 
> the ability to change a matrix a refuses to work with immutable ones? Any 
> suggestions?
>
> Thank you!
> Andrey
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to