Comment #41 on issue 1923 by nicolas....@gmail.com: count_ops doesn't return a count (by default)
http://code.google.com/p/sympy/issues/detail?id=1923

Chris, trying to implement issue 2011, I found the following bug today:

In [6]: from sympy.physics.secondquant import BKet

In [7]: count_ops(BKet([n]))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/nicolas/Programmation/sympy/<ipython console> in <module>()

/home/nicolas/Programmation/sympy/sympy/core/function.pyc in count_ops(expr, visual)
   1085         while args:
   1086             a = args.pop()
-> 1087             if a.is_Rational:
   1088                 #-1/3 = NEG + DIV

   1089                 if a is not S.One:

AttributeError: 'tuple' object has no attribute 'is_Rational'


This is because BKet arguments are not of type Expr:

In [8]: BKet([n]).args
Out[8]: ((n,),)

In [9]: type(BKet([n]).args[0])
Out[9]: <type 'tuple'>

I think it should be of type Tuple instead.

I tried to play a bit with sympy/physics/seconquant.py, but I have few knowledge in physics, and I'm afraid of breaking things.
It would be great if you could have a look at this...

Alternatively, one may modify count_ops(), but I don't think its the proper to way this.

--
You received this message because you are subscribed to the Google Groups 
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-patches+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-patches?hl=en.

Reply via email to