File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -1740,7 +1740,28 @@ class NaN(Number):
1740
1740
import sage.all as sage
1741
1741
return sage.NaN
1742
1742
1743
- class Add (Basic ):
1743
+
1744
+ class AssocOp (Basic ):
1745
+
1746
+ @classmethod
1747
+ def _from_args (cls , args ):
1748
+ if len (args) == 0 :
1749
+ return cls .identity
1750
+ elif len (args) == 1 :
1751
+ return args[0 ]
1752
+
1753
+ obj = super (AssocOp, cls ).__new__(cls , * args)
1754
+ return obj
1755
+
1756
+ @classmethod
1757
+ def make_args (cls , expr ):
1758
+ if isinstance (expr, cls ):
1759
+ return expr.args
1760
+ else :
1761
+ return (sympify(expr),)
1762
+
1763
+
1764
+ class Add (AssocOp ):
1744
1765
1745
1766
def __new__ (cls , *args , **kwargs ):
1746
1767
cdef symengine.vec_basic v_
@@ -1783,7 +1804,7 @@ class Add(Basic):
1783
1804
inc(iter )
1784
1805
return d
1785
1806
1786
- class Mul (Basic ):
1807
+ class Mul (AssocOp ):
1787
1808
1788
1809
def __new__ (cls , *args , **kwargs ):
1789
1810
cdef symengine.vec_basic v_
You can’t perform that action at this time.
0 commit comments