1
1
// SWIG file NumericalMathFunction.i
2
2
// Author : $LastChangedBy: dutka $
3
// Date : $LastChangedDate: 2008-10-15 17:56:07 +0200 (mer. 15 oct. 2008) $
4
// Id : $Id: NumericalMathFunction.i 972 2008-10-15 15:56:07Z dutka $
3
// Date : $LastChangedDate: 2010-01-27 14:00:03 +0100 (mer. 27 janv. 2010) $
4
// Id : $Id: NumericalMathFunction.i 1452 2010-01-27 13:00:03Z dutka $
7
7
#include "NumericalMathFunction.hxx"
8
8
#include "PythonNumericalMathEvaluationImplementation.hxx"
13
struct traitsPythonType<OpenTURNS::Base::Func::NumericalMathFunction>
15
typedef _PyObject_ Type;
20
OpenTURNS::Base::Func::NumericalMathFunction
21
convert<_PyObject_,OpenTURNS::Base::Func::NumericalMathFunction>(PyObject * pyObj)
23
if (!PyCallable_Check( pyObj )) {
24
throw OT::Base::Common::InvalidArgumentException(HERE) << "Argument is not a callable object (function or class)";
27
return OpenTURNS::Base::Func::NumericalMathFunction(new OpenTURNS::Base::Func::NumericalMathFunctionImplementation(new OpenTURNS::Base::Func::PythonNumericalMathEvaluationImplementation(pyObj) ) );
31
} /* namespace OpenTURNS */
20
def getInputNumericalPointDimension(self) :
44
def getInputDimension(self) :
23
def getOutputNumericalPointDimension(self) :
47
def getOutputDimension(self) :
26
50
def __call__(self, X) :
29
if ( type(X) not in (types.TupleType, types.ListType) ):
53
if ( type(X) not in (types.TupleType, types.ListType) ):
30
54
raise TypeError("Expect sequence argument like a list or a tuple")
31
if (len(X) != self.n):
32
raise TypeError("Expect sequence argument of length %d. Got %d" % (self.n, len(X)) )
36
if ( type(Y) not in (types.TupleType, types.ListType) ):
37
raise TypeError("Expect sequence argument like a list or a tuple as f's return value. Check f method")
38
if (len(Y) != self.p):
39
raise TypeError("Expect sequence argument of length %d. Got %d. Check f method" % (self.p, len(Y)) )
56
raise TypeError("Expect sequence argument of length > 0")
57
if ( type(X[0]) not in (types.TupleType, types.ListType) ):
59
if ( type(Y) not in (types.TupleType, types.ListType) ):
60
raise TypeError("Expect sequence argument like a list or a tuple as f's return value. Check f method")
61
if (len(Y) != self.p):
62
raise TypeError("Expect sequence argument of length %d. Got %d. Check f method" % (self.p, len(Y)) )
66
# if ( type(Y) not in (types.TupleType, types.ListType) ):
67
# raise TypeError("Expect sequence argument like a list or a tuple as f's return value. Check fsample method")
68
# if (len(Y) != len(X)):
69
# raise TypeError("Expect sequence argument of length %d. Got %d. Check fsample method" % (len(X), len(Y)) )
70
# for i in range(len(X)):
71
# if ( len(Y[i]) != self.p ):
72
# raise TypeError("Expect sequence argument of length %d at position %d. Got %d. Check fsample method" % (self.p, i, len(Y[i])) )
78
# def fsample(self, X) :
80
# for i in range(len(X)):
81
# Y.append(self.f(X[i]))
48
86
%template(NumericalMathFunctionImplementationTypedInterfaceObject) OpenTURNS::Base::Common::TypedInterfaceObject<OpenTURNS::Base::Func::NumericalMathFunctionImplementation>;
57
95
NumericalMathFunction(PyObject * pyObj)
59
if (!PyCallable_Check( pyObj )) {
60
throw OT::Base::Common::InvalidArgumentException(HERE) << "Argument is not a callable object (function or class)";
63
return new OpenTURNS::Base::Func::NumericalMathFunction(new OpenTURNS::Base::Func::NumericalMathFunctionImplementation(new OpenTURNS::Base::Func::PythonNumericalMathEvaluationImplementation(pyObj) ) );
97
return new OpenTURNS::Base::Func::NumericalMathFunction( OpenTURNS::convert<OpenTURNS::_PyObject_,OpenTURNS::Base::Func::NumericalMathFunction>(pyObj) );
100
OpenTURNS::Base::Type::NumericalPoint operator() (PyObject * pyObj) {
101
return self->operator()( OpenTURNS::convert<OpenTURNS::_PySequence_, OpenTURNS::Base::Type::NumericalPoint>( pyObj ) );