Status: Started Owner: [email protected] Labels: Type-Defect Priority-Medium
New issue 1915 by [email protected]: Unify make_list with as_Add/as_Mul http://code.google.com/p/sympy/issues/detail?id=1915 make_list(expr, Add) and expr.as_Add() are two ways of doing the exact same thing: finding args such that expr == Add(*args). Clearly, this is one too many. Both approaches have problems actually. The first one lives in sympy.utilities but is used in the core and cannot easily be customised for different kinds of operations. The second forces every object to grow one additional method per existing operation and requires modifications to the core every time a new operation is added. So, I think that the best way of providing this functionality is to implement it as a classmethod on AssocOp so that all operations inherit it and can override it if required. I've coded it in [http://github.com/rlamy/sympy/tree/as_args]. The syntax is Add.as_args(expr) (does anyone have an idea for a better name?). The first (and, so far, only) commit in my branch is a straightforward replacement of the existing methods, but there are a few enhancements that seem easy to do: * return an empty list for the operation's identity (Add.as_args(0) -> []) * return the actual argument tuple, instead of making an unnecessary copy * for And and Or, return the internal frozenset representation, instead of a tuple -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings -- 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.
