Hi Aaron Meurer, Thanks, it works!
Ronghai 在 2015年9月21日星期一 UTC+2下午8:16:20,Aaron Meurer写道: > > subs should only be used to replace sympy expressions with sympy > expressions. To evaluate a sympy expression at a numpy array, you > should lambdify() it first. > > In [10]: f0 = lambdify((a, b, c), f) > > In [12]: f0(array1, array2, array3) > Out[12]: array([2, 1, 1]) > > Aaron Meurer > > On Mon, Sep 21, 2015 at 1:01 PM, Ronghai Wu <csu.wu...@gmail.com > <javascript:>> wrote: > > Dear Sympy developers and users, > > > > Could anyone help me with the following problem: > > substitute a, b, c by arrays in expression f = a*b*c. For example, I get > > "ValueError: The truth value of an array with more than one element is > > ambiguous" if running: > > import sympy > > import numpy > > sympy.var('a,b,c') > > f = a*b*c > > array1 = numpy.random.randint(1,3,3) > > array2 = numpy.random.randint(1,3,3) > > array3 = numpy.random.randint(1,3,3) > > f.subs([[a, array1], [b, array2], [c, array3]]) > > > > Best Regards > > Ronghai Wu > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to sympy+un...@googlegroups.com <javascript:>. > > To post to this group, send email to sy...@googlegroups.com > <javascript:>. > > Visit this group at http://groups.google.com/group/sympy. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/sympy/89d85fa0-8151-40da-ab0c-6d6f6d34a66e%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/32e3844c-8a17-490a-89b3-2314a8a40fb6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.