Comment #3 on issue 3858 by tadej.ja...@gmail.com: Calling subs() on a
logical function sometimes returns "bool" type and
sometimes "sympy.core.numbers.Zero/One" type
http://code.google.com/p/sympy/issues/detail?id=3858
@smi...@gmail.com:
Thanks for the explanation. The 'simultaneous=True' works for me.
I wonder, though, if this behavior might deter new users of SymPy. The
original problem I had was something like:
from sympy import *
import numpy as np
x1, x2, x3, x4, x5, x6, x7, x8 = symbols("x1:9")
variables = (x1, x2, x3, x4, x5, x6, x7, x8)
function = Or(And(Not(x2), Not(x8)), And(Not(x2), x1, x5, x6), And(Not(x3),
x2, x7, x8), And(Not(x7), x3))
print "Logical function: ", pretty(function)
X_1 = [1, 1, 0, 1, 0, 1, 1, 0]
y_1 = function.subs(zip(variables, X_1))
print "Input: {}, Output type: {}".format(X_1, type(y_1))
X_2 = [1, 1, 0, 1, 0, 0, 0, 0]
y_2 = function.subs(zip(variables, X_2))
print "Input: {}, Output type: {}".format(X_2, type(y_2))
y = np.zeros(2, dtype="int")
y[0] = y_1 # fails with: TypeError: long() argument must be a string or a
number, not 'Zero'
y[1] = y_2
In essence, this type of behavior causes strange problems down the road,
e.g. when integrating SymPy with NumPy. When I first saw the error, I was
quite confused.
Maybe an example of this type added at the end of section
http://docs.sympy.org/dev/modules/logic.html#forming-logical-expressions
would clear the confusion?
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.