On Sun, Oct 19, 2014 at 12:34 AM, Duane Nykamp <[email protected]> wrote:
> 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.

I'd consider this to be a bug.

Aaron Meurer

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

-- 
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/CAKgW%3D6J67e-Z5-Yx4HGB6Xv_QYNEfsh6GrujbAeZg6vE0x4PLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to