Hello, 

No, that's not possible. OpenTURNS' functions return vectors anyway. 

If you absolutely have to reuse func as is you could still create a decorator 
that wraps your function and packs it in a list. 

j 

> De: "roy" <[email protected]>
> À: "users" <[email protected]>
> Envoyé: Mercredi 1 Février 2017 14:07:35
> Objet: [ot-users] PythonFunction from a scalar output function

> Hi,

> Is it possible to create a PythonFunction without the function returning a 
> list?

> This does not work:

> def func(x):
> f = 0.
> for i in range(2):
> f += np.sin(x[i]) * np.sin((i + 1) * x[i]** 2 / np.pi) ** (2 * 10)

> return -f

> f = ot.PythonFunction(2, 1, func)

> This works:

> def func(x):
> f = 0.
> for i in range(2):
> f += np.sin(x[i]) * np.sin((i + 1) * x[i]** 2 / np.pi) ** (2 * 10)

> return [-f]

> f = ot.PythonFunction(2, 1, nunc)

> Thanks,

> Pamphile ROY
> _______________________________________________
> OpenTURNS users mailing list
> [email protected]
> http://openturns.org/mailman/listinfo/users

-- 
Julien Schueller 
Phimeca Engineering 
www.phimeca.com 
_______________________________________________
OpenTURNS users mailing list
[email protected]
http://openturns.org/mailman/listinfo/users

Reply via email to