#17394: TypeError in Expression.simplify_hypergeometric()
-----------------------------+------------------------
       Reporter:  mjo        |        Owner:
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.5
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------

Comment (by nbruin):

 It's simply this:
 {{{
 sage: A=SR(x+y+x*y)
 sage: A.operator()(*A.operands())
 TypeError: op_add expected 2 arguments, got 3
 sage: A.operator()
 sage: A.operator()
 <built-in function add>
 }}}
 We should probably not use the built-in function add to mark addition
 etc., but instead use a variadic version. Same would apply to mul. This
 issue arises in a lot of places. See for instance `maxima_lib.add_vararg`.
 It's probably a change that would need to be made in pynac somewhere.

 Other point:
 {{{
 op(*map(lambda o: o.simplify_hypergeometric(algorithm), ops))
 }}}
 is both more compactly and more efficiently expressed in python by
 {{{
 op(*(o.simplify_hypergeometric(algorithm) for o in ops))
 }}}
 Compare:

 {{{
 sage: def l(*args):
 ....:         return list(args)
 ....:
 sage: %timeit l( *[a.bit_length() for a in xrange(100)] )
 100000 loops, best of 3: 10.2 µs per loop
 sage: %timeit l( *(a.bit_length() for a in xrange(100)) )
 100000 loops, best of 3: 12.9 µs per loop
 sage: %timeit l( *map(lambda a: a.bit_length(), xrange(100)) )
 10000 loops, best of 3: 17.9 µs per loop
 }}}

 Basically: don't use "map" in python unless it's considerably more
 convenient than the corresponding list comprehension.

--
Ticket URL: <http://trac.sagemath.org/ticket/17394#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to