Given changes with booleans as discussed in
https://groups.google.com/forum/#!topic/sympy/82ls0doW6Nk, I'm trying to
develop a new approach to testing the number of True's in Tuple.
With earlier versions of sympy, if
thelist=Tuple(False, True, False)
the following worked
sum(thelist)==1
Now, I'm trying to use the condition
thelist.count(True)==1
with parse_expr.
The following works as expected
In [25]: parse_expr("(True,False,False).count(True)==1",
transformations=(auto_symbol, auto_number, split_symbols))
Out[25]: True
but, if I add implicit_multiplication, it breaks.
In [26]: parse_expr("(True,False,False).count(True)==1",
transformations=(auto_symbol, auto_number, split_symbols,
implicit_multiplication))
---------------------------------------------------------------------------
[snip]
TypeError: unsupported operand type(s) for *: 'builtin_function_or_method'
and 'bool'
I don't suppose there is a way to get implicit_multiplication to realize
that .count() is a function and it shouldn't replace the function
application with a multiplication.
Or are there better ways of determining the number of True's in the Tuple
using parse_expr?
Thanks,
Duane
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/fbd3ae7a-1033-4d15-981b-d2b9799cb8be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.