Updates:
        Labels: -Priority-Medium Priority-High

Comment #9 on issue 3025 by [email protected]: Piecewise evaluate=False does not work when conditions are boolean
http://code.google.com/p/sympy/issues/detail?id=3025

To summarize a discussion from the pull request:

Piecewise((x, x > 1), (0, True), nan) in Sean's branch evaluates to 0, because (0, True) is parsed as an expr, cond pair, and since the condition is True, it returns the expression. evaluate=False would allow to keep this from evaluating, which would be desirable if x is later evaluated to something greater than 1, in which case you would get x (whatever it is), not 0 (or at least that was my opinion; Ronan hasn't stated his yet).

In other words, you can consider Piecewise((x, x > 1), (0, True), nan) as

if x > 1:  return x
elif True: return 0
else: return nan

If x is given, this should return x, not 0.

On the other hand, if Piecewise does not evaluate to explicitly True conditions, it will be useless.

Let me know if I've left anything out. I don't know if you wanted to discuss the IfElse here as well.

#6 describes current behaviour in master. I think that it's wrong, and that Piecewise((x, x>1), (0, True), (1, False), (2, True)) should always be canonicalised to Piecewise((x, x>1), (0, True)), irrespective of issue 2626.

I definitely agree that it's wrong, and was probably never intentioned to do that, but rather is just a side effect of the way the current parser/printer works.

It doesn't make sense to say "Piecewise((x, x>1), (0, True)), irrespective of issue 2626." because those mean different things in master and in Sean's branch (or technically, master and Sean's branch after we end the deprecation cycle). That's why I think we should just discuss things in terms of the new syntax, so that we are clear about what we mean (hence, we could talk about Piecewise((x, x>1), (0, True), nan), which is unambiguous in the new syntax due to redundancy, even with deprecation).

This is what I meant when I said "let's do all discussions there," by the way, that we should discuss things using the new syntax, not necessarily that the discussion itself should be in the pull request. Sorry if there was ambiguity there.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to