Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New 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

Here is a small example illustrating what I mean:
from sympy import *
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))

The output on my machine with sympy from git (https://github.com/sympy/sympy/commit/9d7f420e5c3e18bc037d6ba55972b57f467e02b0): Logical function: (x₃ ∧ ¬ x₇) ∨ (¬ x₂ ∧ ¬ x₈) ∨ (x₁ ∧ x₅ ∧ x₆ ∧ ¬ x₂) ∨ (x₂ ∧ x₇ ∧ x₈ ∧ ¬ x₃) Input: [1, 1, 0, 1, 0, 1, 1, 0], Output type: <class 'sympy.core.numbers.Zero'>
Input: [1, 1, 0, 1, 0, 0, 0, 0], Output type: <type 'bool'>

--
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.


Reply via email to