Comment #15 on issue 1923 by nicolas.pourcelot: count_ops doesn't return a
count (by default)
http://code.google.com/p/sympy/issues/detail?id=1923
I just realize that previous code will return 0 (and not S.Zero) if expr is
an empty list/set/tuple or dict, even if visual=True.
If this really matters (but I'm not convinced), this could be modified for
example as following:
def count_ops(expr, visual=False):
if visual:
zero = S.Zero
else:
zero = 0
if type(expr) in (set, list, tuple):
return zero + __builtin__.sum(count_ops(a, visual) for a in
expr)
elif type(expr) is dict:
return zero + __builtins__.sum(count_ops(a, visual=True) for a
in expr.iteritems())
elif not isinstance(expr, Expr):
return zero
return expr.count_ops()
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.