-
-
Save Krastanov/2601322 to your computer and use it in GitHub Desktop.
At the moment we have: | |
====================== | |
<~~~ is for metaclasses | |
| \ or / is for subclasses | |
Basic <~~~~~~~~ WithAssumptions | |
blah / \ | | |
\ / \ | | |
Expr Application <~~~ FunctionClass | |
\ / | |
\ / | |
Function | |
But changing it to: | |
=================== | |
Basic <~~~~~~~~ WithAssumptions | |
blah | | | |
\ | | | |
Expr | | |
| | | |
| | | |
Application <~~~ FunctionClass | |
| | |
Function | |
is a two line change in functions.py and does not cause any test failures | |
at least for | |
[./bin/test ./bin/doctest] [core function logic util] | |
Is there any drawback in the second approach? | |
I consider its simplicity an advantage. |
On a similar note:
Max is defined as Max(MinMaxBase, Application, Basic)
. Removing Basic
does not trigger any test failures. The same goes for Min.
On a similar note: BasicType
and BasicMeta
can be merged (BasicType
does absolutely nothing).
On a similar note: Atom and AtomicExpr can be merged (Atom is used only by AtomicExpr).
But in theory there could be a class that should derive from Atom but not AtomicExpr.
@asmeurer, I believe that your comment is based in the idea that Expr represents only a complex number and Basic represent general mathematical object. But I think (as mentioned on the mailing list) that Expr and Basic are awfully mixed in practice throughout the code base.
Disclaimer: I am really unsure about the correctness of my comment.
Do you have any specific examples where they are mixed? The only one I can think of off the top of my head is Symbol, which derives from both Boolean and Expr.
As an example for my case, I can't find where Sean's old implementation of http://code.google.com/p/sympy/issues/detail?id=2531 is, but my guess is that those classes were Atom but not AtomicExpr.
@asmeurer, I mentioned them on the mailing list, but I am unsure where is the best place to have this discussion so I am posting them also here:
Most of these are operator on Hilbert spaces, Hilbert space vectors or some kind of containers like matrices:
sympy/core/relational.py:class Relational(Expr, EvalfMixin):
sympy/core/function.py:class Lambda(Expr):
sympy/core/function.py:class Subs(Expr):
sympy/matrices/expressions/matexpr.py:class MatrixExpr(Expr):
sympy/physics/quantum/spin.py:class WignerD(Expr):
sympy/physics/quantum/qexpr.py:class QExpr(Expr):
sympy/physics/quantum/innerproduct.py:class InnerProduct(Expr):
sympy/physics/quantum/anticommutator.py:class AntiCommutator(Expr):
sympy/physics/quantum/tensorproduct.py:class TensorProduct(Expr):
sympy/physics/quantum/commutator.py:class Commutator(Expr):
sympy/physics/quantum/dagger.py:class Dagger(Expr):
sympy/physics/quantum/cg.py:class Wigner3j(Expr):
sympy/physics/quantum/cg.py:class Wigner6j(Expr):
sympy/physics/quantum/cg.py:class Wigner9j(Expr):
sympy/physics/gaussopt.py:class BeamParameter(Expr):
sympy/physics/secondquant.py:class Dagger(Expr):
sympy/physics/secondquant.py:class TensorSymbol(Expr):
sympy/physics/secondquant.py:class SqOperator(Expr):
sympy/physics/secondquant.py:class FockState(Expr):
sympy/physics/secondquant.py:class PermutationOperator(Expr):
sympy/series/order.py:class Order(Expr):
sympy/tensor/indexed.py:class Indexed(Expr):
sympy/tensor/indexed.py:class IndexedBase(Expr):
sympy/tensor/indexed.py:class Idx(Expr):
Maybe it is because the EvalfMixing that is part of Expr. But I consider it appropriate for Application as well (say the Application is a linear application - it is appropriate to demand evaluation of the coefficients of that application).