What "count_ops()" means?

19 views
Skip to first unread message

SAHIL SHEKHAWAT

unread,
Apr 10, 2014, 9:40:40 AM4/10/14
to sy...@googlegroups.com
Hey everyone, I have been working with count_ops() so that logic functions can also be counted as an operation but there has been a bit of confusion about its real meaning.

Firstly, I don't want to count "Basic(x)" as an operation as all the expression reaching this functions (even if they are Symbols) are themselves instances of "Basic" class, and "Expr(x).count_ops()" also returns 0 which is the way Sympy handles other expressions. So, Should i include it?

Secondly, Logic functions don't raise exceptions when:
   1) There are less number of arguments then required. like
               
    IN  [1] : And(x)
    OUT[1]: x
   
   2) When any argument of logic function is an empty tuple

   IN   [2]: sympify(And( x, () ))
   OUT[2]: And( (), x)
  
   3) Expressions which don't even make sense are executed without even a hiccup 

   IN   [3]: And( x, (x,y) )
   OUT[3]: And( x, (x,y) )
   
These bugs in the logic function are resulting in all types of funny results while using "count_ops()" (After my codes). So , should i take care of all these bugs in the "count_ops()" 's code?
Please help me by reviewing my PR https://github.com/sympy/sympy/pull/7303 as this is for my Gsoc's patch. 
Any type of help is highly appreciated. Thanks

Aaron Meurer

unread,
Apr 10, 2014, 7:31:48 PM4/10/14
to sy...@googlegroups.com
My problem with count_ops is that it claims to count the operations, but it doesn't make it clear what an "operation" is. I would assume it meant a node in the expression tree with children, but it does some weird stuff with NEG and DIV, and until your PR, ignores all expressions except for the common ones like ADD and MUL.

I wouldn't worry about the logic functions not handling tuples. That is a separate issue. And(x) -> x is correct though. That's similar to Add() -> 0 or Add(x) -> x.

Aaron Meurer


--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
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/b27dc142-59b3-42c9-848a-861738a7163f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

SAHIL SHEKHAWAT

unread,
Apr 10, 2014, 9:11:10 PM4/10/14
to sy...@googlegroups.com
I have tried to do the same by taking "Boolean" in account and handling them separately and all the other expressions separately..https://github.com/sympy/sympy/pull/7303 as boolean are counted when there is more than one argument but for basic number of arguments are its children.

SAHIL SHEKHAWAT

unread,
Apr 10, 2014, 9:47:07 PM4/10/14
to sy...@googlegroups.com
Can you please restart the travis test https://travis-ci.org/sympy/sympy/builds/22709118 ,It took more than 50minutes and errored.
thanks
Reply all
Reply to author
Forward
0 new messages