The problem with the is_Foo construct is that every basic has to carry it, so every object grows. The reason (maybe historic) there are some there is that its faster to ask is_Foo than to do isinstance a lot and the core needs some faster things. For bits that aren't checked very much we should try to keep it out of the core (maybe put it in the assumptions).
Of course once Indexed elements start propogating to other modules it might be necessary to do this. For now I vote that we either include a depth first search for the properties. -- Andy On Thu, Sep 23, 2010 at 6:27 PM, Nicholas Kinar <n.ki...@usask.ca> wrote: > >> You should also know about pre/post_order_traversal (both must be imported >> from sympy.utilities.iterables), which let you dig all the way down in an >> expression tree. >> >> In [109]: from sympy.utilities.iterables import preorder_traversal, >> postorder_traversal >> >> In [110]: preorder_traversal(sin(x**2) + 4*x**3) >> Out[110]:<generator object preorder_traversal at 0x102415a00> >> >> In [111]: list(preorder_traversal(sin(x**2) + 4*x**3)) >> Out[111]: >> ⎡ ⎛ 2⎞ 3 3 3 ⎛ 2⎞ 2 ⎤ >> ⎣sin⎝x ⎠ + 4⋅x , 4⋅x , 4, x , x, 3, sin⎝x ⎠, x , x, 2⎦ >> >> In [112]: list(postorder_traversal(sin(x**2) + 4*x**3)) >> Out[112]: >> ⎡ 3 3 2 ⎛ 2⎞ ⎛ 2⎞ 3⎤ >> ⎣4, x, 3, x , 4⋅x , x, 2, x , sin⎝x ⎠, sin⎝x ⎠ + 4⋅x ⎦ >> >> Also, as Chris said, using .atoms() to find what IndexedElements there are >> is useful. There maybe ought to be some .is_IndexedElement attribute on >> IndexedElement, just as there is for every other major class. Øyvind, what >> do you think? >> >> Aaron Meurer >> >> > > Thanks, Aaron; I also agree that there should be some way to check and see > if a class is of a particular type, and it would be terrific if > IndexedElement would also have this. > > Nicholas > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sy...@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.