possible Matrix constructor bug

9 views
Skip to first unread message

Adrian Seyboldt

unread,
Mar 14, 2012, 7:26:53 AM3/14/12
to sy...@googlegroups.com
Hello,

When creating a Matrix from another one, no new object is created

m1 = Matrix(2, 2, range(4))
m2 = Matrix(m1)

m1 is m2

returns True, so changing m1 will also change m2. I know I can use m1.clone(), but
since SomeClass() usually creates a new object, this took me rather by surprise.

Is this intended behavior?


Adrian Seyboldt

Matthew Rocklin

unread,
Mar 14, 2012, 11:53:35 AM3/14/12
to sy...@googlegroups.com
Hrm, yes, this should probably change. 

Having things the way they are now accelerates a few internal functions. This acceleration probably isn't worthwhile though given the confusion you bring up. I'll send in a PR with this change in a bit.

In general the internals of Matrices were changed around a bit in a recent commit. Bug reports like this are very useful. 

-Matthew




Adrian Seyboldt

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/kmGB44EhawEJ.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.

Matthew Rocklin

unread,
Mar 14, 2012, 12:47:46 PM3/14/12
to sy...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages