On Fri, Dec 14, 2012 at 3:05 AM, Aaron Meurer <asmeu...@gmail.com> wrote: > > I agree that a slice should return a Matrix, though, to be consistant.
Hi and thanks people for your replies. It is good to know that there is a workaround by using index by tuple (i.e. [5,:] or [5:,:]) notation for now, but I also would expect the slice of a Matrix to be a Matrix, at least when the Matrix is a Vector. The "at least" clause being important it may not be meaningful or advisable to have a non-vector matrix suddenly turn into a vector when indiced by a single integer -- so it would be appropriate to only output a list object in that case. But this would mean inconsistent output from operator[] -- list when it is given a single integer index on a non-vector, Matrix otherwise. How about this -- it doesn't seem as if Matrix has any operator() i.e. __call__: >>> from sympy import Matrix >>> a=Matrix(2,2,(1,2,3,4)) >>> a(1,1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'MutableMatrix' object is not callable Eigen (http://eigen.tuxfamily.org/) has the operator() to take row,col indices (simply because C++ doesn't allow [] to do so). See: http://eigen.tuxfamily.org/dox/classEigen_1_1DenseCoeffsBase_3_01Derived_00_01ReadOnlyAccessors_01_4.html and http://eigen.tuxfamily.org/dox/TutorialMatrixClass.html#TutorialMatrixCoeffAccessors How about defining that operator() (i.e. __call__) in SymPy as a synonym to [] except that it should only accept an index as per the shape of the matrix? That is, if it is not a vector, it should accept only a two-tuple index, and if it is a vector, it should accept only an integer index. Else it should raise an error. This way, we can retain the current behaviour of operator[] but at the same time provide consistent output from operator() of type Matrix only. BTW I hope that the output of such an operator() can be used as both lvalue and rvalue (else it wouldn't be useful)... -- Shriramana Sharma -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.