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.wurong...@gmail.com> 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+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/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/CAKgW%3D6%2BcXiCLd5bqJgALVg5U-UnL%3DSKLD8yEZKNx4CLkJnFEiQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.