Why are some classes not subclass of Basic?

44 views
Skip to first unread message

JS S

unread,
Nov 29, 2019, 2:23:29 AM11/29/19
to sympy
I'm just being curious.
Some classes in sympy, such as Matrix in matrices package or Vector in physics.vector package, are not subclass of Basic.
Is this intentional?

Aaron Meurer

unread,
Nov 29, 2019, 4:26:27 PM11/29/19
to sympy
MutableMatrix doesn't subclass from Basic because Basic subclasses
have to be mutable. That's why there is an ImmutableMatrix class,
which does subclass from Basic. Matrix aliases MutableMatrix for
backwards compatibility. I'm not sure about Vector but I think it is
similar.

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/369cebed-3c6b-4e06-b729-858222baed5d%40googlegroups.com.

Jason Moore

unread,
Nov 29, 2019, 4:56:27 PM11/29/19
to sympy
Same reason for the physics vector. It relies on mutability for functionality.

Jason

Lee Smith

unread,
Nov 29, 2019, 7:30:03 PM11/29/19
to sy...@googlegroups.com, Aaron Meurer
Thank you for your note about Matrix and Basic.  These are some of the lesser known parts of sympy [at least to me].

I am preparing an Intermediate Python course, probably for summer/fall.  You you point me to sites/books which outline/list topics beyond Matplotlib, Numpy, Pandas and Sympy ?

lee smith

JS S

unread,
Nov 30, 2019, 2:52:06 AM11/30/19
to sympy
Thanks! But one more question, may I ask?

Why is ImmutableDenseNDimArray in tensor module NOT subclass of Expr, while ImmutableMatrix is subclass of Expr?

The docstring of Expr says that Expr needs arithmetic operations to be defined, but I can't see the difference between these two.


2019년 11월 30일 토요일 오전 6시 26분 27초 UTC+9, Aaron Meurer 님의 말:
MutableMatrix doesn't subclass from Basic because Basic subclasses
have to be mutable. That's why there is an ImmutableMatrix class,
which does subclass from Basic. Matrix aliases MutableMatrix for
backwards compatibility. I'm not sure about Vector but I think it is
similar.

Aaron Meurer

On Fri, Nov 29, 2019 at 12:23 AM JS S <jeeso...@gmail.com> wrote:
>
> I'm just being curious.
> Some classes in sympy, such as Matrix in matrices package or Vector in physics.vector package, are not subclass of Basic.
> Is this intentional?
>
> --
> 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 sy...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages