Sympy Matrix.col_insert not working python 3 -


so have tried following code copied straight docs, , seems me function not doing supposed to:

import sympy sp m = sp.matrix(3,3,lambda i,j: i+j) v = sp.matrix.zeros(3, 1) m.col_insert(1,v)  print(m) 

gives output

matrix([[0, 1, 2], [1, 2, 3], [2, 3, 4]]) 

not per teh docs link.

[0, 0, 1, 2] [1, 0, 2, 3] [2, 0, 3, 4]  

the same goes row_insert.

what doing wrong?

in version 3 (and earlier) following

>>> import sympy sp >>> m = sp.matrix(3,3,lambda i,j: i+j) >>> v = sp.matrix.zeros(3, 1) >>> m.col_insert(1,v) matrix([ [0, 0, 1, 2], [1, 0, 2, 3], [2, 0, 3, 4]]) >>> print(m) matrix([[0, 1, 2], [1, 2, 3], [2, 3, 4]]) 

m not modified in place, new matrix created col_insert method -- notice didn't print after command, new matrix returned command itself. method col_del, on other hand, works in place:

>>> m.col_del(0) >>> m matrix([ [1, 2], [2, 3], [3, 4]]) 

Comments