details: http://hg.sympy.org/sympy/rev/1ab457e8e482 changeset: 1834:1ab457e8e482 user: Andy R. Terrel <[EMAIL PROTECTED]> date: Fri Oct 17 08:33:14 2008 +0200 description: This patch implements doit for piecewise functions.
diffs (38 lines): diff -r d040911a2af5 -r 1ab457e8e482 sympy/functions/elementary/piecewise.py --- a/sympy/functions/elementary/piecewise.py Fri Oct 17 08:32:44 2008 +0200 +++ b/sympy/functions/elementary/piecewise.py Fri Oct 17 08:33:14 2008 +0200 @@ -89,6 +89,20 @@ cls.narg = nargs return None + def doit(self, **hints): + new_ecpairs = [] + for expr, cond in self.args: + if hasattr(expr,'doit'): + new_expr = expr.doit(**hints) + else: + new_expr = expr + if hasattr(cond,'doit'): + new_cond = cond.doit(**hints) + else: + new_cond = cond + new_ecpairs.append( (new_expr, new_cond) ) + return Piecewise(*new_ecpairs) + def _eval_derivative(self, s): return Piecewise(*[(diff(expr,s),cond) for expr, cond in self.args]) diff -r d040911a2af5 -r 1ab457e8e482 sympy/functions/elementary/tests/test_piecewise.py --- a/sympy/functions/elementary/tests/test_piecewise.py Fri Oct 17 08:32:44 2008 +0200 +++ b/sympy/functions/elementary/tests/test_piecewise.py Fri Oct 17 08:33:14 2008 +0200 @@ -31,6 +31,10 @@ assert p.subs(x,-1) == 1 assert p.subs(x,1) == log(1) + # Test doit + f_int = Piecewise((Integral(x,(x,0,1)), x < 1)) + assert f_int.doit() == Piecewise( (1.0/2.0, x < 1) ) + # Test differentiation f = x fp = x*p --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-commits" group. To post to this group, send email to sympy-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-commits?hl=en -~----------~----~----~----~------~----~------~--~---