I agree with your statement that: "These all operations be allowed". For 
the M.row_del( ) for negative indices, should I Open an Issue and Fix it ?

On Monday, June 1, 2015 at 8:02:33 PM UTC+5:30, Chris Smith wrote:
>
> The question is how you would append a row using the insert method if you 
> disallowed indices that are out of range. I agree that the negative indice 
> behavior is wrong for deletion: it should have deleted the first row as you 
> indicate.
>
> On Sunday, May 31, 2015 at 7:13:14 AM UTC-5, Gaurav Dhingra wrote:
>>
>> Hi all
>>
>> >>> from sympy import *
>> >>> M = Matrix( [ [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6] ] )
>> >>> M.row_del ( 8 )                                            # any 
>> index >= M.rows to be used
>> >>> print( M )
>> Matrix( [ [ 1, 2, 3], [2, 3, 4], [3, 4, 5] ] )               # deletes 
>> the last row of Matrix for Index >= M.rows
>>
>> >>> N = Matrix( [ [ 1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6] ] )
>> >>> N.row_del( -10 )
>> >>> print( N )                                                     # 
>> deletes the last row of Matrix with any `Negative Index`
>> Matrix( [ [ 1, 2, 3], [2, 3, 4], [3, 4, 5] ] )
>>
>> But the output for .row_insert() shows different behavior
>>
>> >>> M = Matrix( [ [1, 2, 3], [2, 3, 4], [3, 4, 5] ] )
>> >>> M.row_insert ( 10, Matrix( [ [ 5, 5, 5 ] ] ) )
>> Matrix( [ [1, 2, 3], [2, 3, 4], [3, 4, 5], [5, 5, 5] ] )   # inserts the 
>> row at the very end for Index >= M.rows
>>
>> >>> N = Matrix( [ [ 1, 2, 3], [2, 3, 4], [3, 4, 5] ] )
>> >>> N.row_insert( -10, Matrix( [ [5, 5, 5 ] ] ) )
>> Matrix( [ [5, 5, 5], [1, 2, 3], [2, 3, 4], [3, 4, 5] ] )     # inserts 
>> the row at the very beginning for `Negative Index`
>>
>>
>> First of all i  expected that an IndexError be raised in all cases. 
>> Because i think it should follow something like  a = [1, 2, 3] and del a[ 
>> 10 ] which raises an error. 
>> But even if not error then it should be more consistent with the indices. 
>> Is it the way the things are expected to work ?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/7ae76c2b-43d0-4c78-89e1-6f0502b58bb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to