On Sat, Jan 11, 2014 at 1:49 AM, Janwillem van Dijk
<jwe.van.d...@gmail.com> wrote:
> Ondřej, I did send you my complete 900 lines scripts to show the problem and
> did not think of making a very simple demo; here it is:

But it doesn't help the rest of us if you only send your script to Ondrej.

>
>
> import sympy
>
> import numpy
>
> n = 2
>
> formula = 'x_0 + x_1'
>
> x = sympy.symbols('x_0:%d' % n, real=True, bounded=True)
>
> y = sympy.sympify(formula)
>
> fx = f_x = sympy.lambdify([x], y, modules='numpy')
>
> X = numpy.ones(n)
>
> print('function value=', fx(X))
>
>
> Python 2.7 returns:
>
> ('function value=', 2.0)
>
> which is obviously the correct answer.
>
>
> Python 3.3 returns:
>
>     print('function value=', fx(X))
>
> TypeError: <lambda>() missing 1 required positional argument: 'x_1'
>
>
> Hope this helps to clearify the point.
> Cheers, Janwillem

I get a TypeError in both. In Python 3 I get the same error as you,
and in Python 2 I get TypeError: <lambda>() takes exactly 2 arguments
(1 given).

If you use fx(*X), it works on both platforms.

Aaron Meurer

>
>
>
> On Tuesday, 7 January 2014 11:04:30 UTC+1, Janwillem van Dijk wrote:
>>
>> I have a SymPy script with a.o.
>>
>> f_mean = lambdify([mu, sigma], mean, modules='numpy')
>>
>>
>> where mean is a function of mu and sigma and mu and sigma are both arrays
>>
>> mu = symbols('mu_0:%d' % n, real=True, bounded=True)
>>
>> sigma = symbols('sigma_0:%d' % n, positive=True, real=True, bounded=True)
>>
>>
>> Under Python 2.7.5+ SymPy 0.12.0 I can use:
>>
>> y = f_mean(x_n, ux_n)
>>
>> returning y as a numpy array of size n when x_n and ux_n are both numpy
>> arrays of size n.
>>
>> However, with Python 3.3.2+ and SymPy 0.7.4.1-git I get (for n=5):
>>
>> y = f_mean(x_n, ux_n)
>> TypeError: <lambda>() missing 10 required positional arguments: 'mu_2',
>> 'mu_3', 'mu_4', 'mu_5', 'sigma_0', 'sigma_1', 'sigma_2', 'sigma_3',
>> 'sigma_4', and 'sigma_5'
>>
>>
>> Which is similar to what I got in Python 2.7 before I added the
>> modules=numpy argument
>>
>> All this on ubuntu 13.10
>>
>>
>> Have I missed something in the docs or did I stumble on a not yet
>> implemented feature?
>>
>> Any help very welcome.heers,
>>
>> Cheers, Janwillem
>>
>>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to