On 01/08/2013 20:03, Eviatar wrote:
Maxima does have an unknown answer for comparisons. I'm in favour of the
exception.
On Wednesday, 9 April 2008 19:18:48 UTC-7, Carl Witty wrote:
I'd like to reopen discussion of #2781, "bool() for SymbolicEquation
should raise an error when it doesn't know the answer". Jason created
a prototype patch to implement this, but gave up on it and closed the
ticket when he was convinced that "this is not pythonic".
I like the "raise an exception" behavior, because it would eliminate
questions asking why form1 and form2 below are different (from this
sage-support thread
http://groups.google.com/group/sage-support/browse_thread/thread/79d0d6d94cfe9526#
<http://groups.google.com/group/sage-support/browse_thread/thread/79d0d6d94cfe9526#>).
(I have seen this exact problem at least twice on sage-support.) What
do you think?
f(x)=x;
def g(x):
if (x>=0):
return f(x)
else:
return f(-x);
show(plot(g(x),(x,-1,1))) #form1
show(plot(g,-1,1)) #form2
Carl
--
You received this message because you are subscribed to the Google
Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.
FWIW, I am too in favour of raising an exception when converting a
symbolic expression to a boolean.
But I would like to note that it is not that convenient to use
"try:...except:..." at the prompt. Can we also add a method to symbolic
expressions, tentatively called truth_value(), that would return 3-state
value:
* True if the expression is always true (tautology)
* False if the expression is always false (negation of tautology)
* None otherwise
Then code might use
if some_exp.truth_value() is not None:
# some_exp is either always true or always false.
and when you want to make sure that some_exp is always true you can use
if some_exp.truth_value():
# some_exp is always true.
TB
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.