If the array classes are supposed to work just like Matrix where they can be added together, and there are array expressions, then it probably should as well. I'm not too familiar with the module, but it doesn't look like array expressions exist yet, so that might be the reason. ImmutableMatrix is Expr because it can be part of a MatAdd or MatMul matrix expression, which subclass from Expr.
There has also been some discussion in the past whether classes that behave like Expr should actually subclass from it or not. For instance, there was some debate about this in the quantum module a while back. I think the conclusion was that they should, because it's too hard to make things work when not doing so. Relational being an Expr is another can of worms. I agree it shouldn't be, at least as it is currently used. IMO there should be separate Expr and Boolean versions of relationals. See https://github.com/sympy/sympy/issues/5031. Ultimately, we still don't really have the best design for custom Expr and Expr-like things. Especially when it comes to things like dispatching inside of Add and Mul, there are some APIs that are there, but we aren't necessarily happy with them. So I wouldn't assume that just because something is done a certain way in SymPy that it is the best way it can be done, particularly when it comes to the class hierarchy and the ways of extending SymPy. Aaron Meurer On Sun, Dec 1, 2019 at 6:59 PM JS S <[email protected]> wrote: > > Sorry for duplicate question - my previous one didn't get any answer so I > cannot but ask again. > > Now, I know that Basic object must be immutable, and Expr object must be able > to be subject to arithmetic operation. > (As far as I know, that is why some classes, e.g. FiniteSet, is instance of > Basic but not Expr). > > But what confuses me is this: > > - ImmutableDenseMatrix is subclass of Expr > - ImmutableSparseMatrix is subclass of Basic, but not Expr. > - ImmutableDenseNDimArray is, unlike its Matrix counterpart, subclass of > Basic but not Expr. > > This is confusing for me: What makes the difference between these three? > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/401e29e2-9a02-41ee-b549-f6d300c9d7cf%40googlegroups.com. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6LcHVz1rkF8idhnv3WhLp36DTc2hZmJtLiZ%2BHJa94MJLw%40mail.gmail.com.
