New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TODO: rebase Addressing Piecewise issues #1009
Commits on Feb 27, 2012
-
New Piecewise syntax and fix Piecewise issues
Piecewise syntax is changed to allow for a more sensible definition of the otherwise condition. Before, an expr/cond pair was specified where cond was given as True. Now, otherwise can either be passed as the final argument after a sequence of expr/cond 2-tuples. The old otherwise syntax using (otherwise, True) raises a deprecation warning. The ExprCondPair class is removed in favor of Tuples to store the expr/cond pairs. The '.as_leading_term()' function is changed so that it takes the sum of all the expressions and, if it is not NaN, the otherwise statement, and returns the leading term of the sum. Ideally, '.as_leading_term()' would return a Piecewise function, but doing this breaks the evaluation of 'abs(x-a).nseries(x, 1)'. Piecewise no longer accepts an Interval as a condition. To implement the same functionality, either the '.as_relational()' or '.contains()' methods of Interval can be used. Piecewise also no longer accepts numbers as conditions. The properties '.exprcondpairs' and '.otherwise' are implemented to easily access the expr/cond pairs and otherwise statement, respectively. Addresses issues: 2101, 2567, 2626, 2710, 2726
-
Changes allowing evaluate keyword to override default behavior of clearing nested Piecewise expressions. More testing of new Piecewise evaluate keyword behavior, including an XFAIL test related to Issue 3025, where evaluate=False does not override behavior when bools are in the conditions. Includes new tests and doctests for '.exprcondpairs' and '.otherwise' properties. Re-enables testing for expressions in expr/cond pairs and the otherwise statement to be Expr or GeometryEntity. GeometryEntity is needed due to the use of Piecewise in the geometry module for '.arbitrary_point()'.
-
Change Piecewise evaluation behavior
Piecewise evaluation now returns the first expression which is explicitly True. If no conditions are True, the otherwise expression is returned. Evaluation can be triggered by setting the 'evaluate' keyword to True. When a boolean is given as a condition, evaluation is enabled unless specifically disabled by setting 'evaluate' to False. In this case, any explicitly False conditions are removed and any explicitly True conditions are given as the otherwise statement. This is done so bools are kept out of args, see Issue 3025. The collapsing of nested Piecewise functions is moved from eval to the __new__ method. This is performed by default, but setting 'evaluate' to False will disable it.
-
Add Piecewise .doit() to perform evaluation
Added a .doit() method to Piecewise functions. This allows for forced evaluation of the Piecewise function. If you want to call doit() to evaluate args but not evaluate the Piecewise function itself, evaluate=False can be added to the hints.
-
Fix other code to work with new Piecewise evaluation
Change '.doit()' keyword for evaluating Piecewise objects from 'evaluate' to 'piecewise' and set other functions to use this to avoid evaluation of Piecewise when required. Having no expr/cond pairs is treated like having bools in the conditions.
-
-
Fix up documentation of Piecewise objects
Improve documentation of Piecewise objects, specifying how the new evaluation functionality works, how it is overridden and the limitations posed by not being able to have bools in the args.
-
Piecewise raises error with bool args and evaluate=False
Change behavior of Piecewise so if bools are given as args and it is given the keyword evaluate=False, it raises a NotImplementedError. This can be changed once classes implementing boolean logic that subclass Basic are implemented. Changes are made in meijerint to parse the args of a Piecewise function used in that module which may have bool conditions, but should not be evaluated. This can be changed to use evaluate=False when the Basic boolean classes are implemented.
-
Fix type checking in Piecewise
Change checking in Piecewise to take expr/cond pairs only in tuples, Tuples or lists, all other expressions go to otherwise. Drop the type checking for the exprs and otherwise statement.
Commits on Mar 16, 2012
Commits on Mar 21, 2012
-
Merge branch 'master' into piecewise_fixes
Conflicts: sympy/functions/elementary/piecewise.py sympy/printing/tests/test_str.py
Commits on Mar 25, 2012
-
Merge branch 'master' into piecewise_fixes
Conflicts: sympy/solvers/tests/test_ode.py
Commits on Mar 31, 2012
-
Merge branch 'master' into piecewise_fixes
Conflicts: sympy/printing/tests/test_str.py sympy/stats/crv_types.py