evalpythonfunction

Evaluates a Python function using its correspondent input arguments.

[status,errorMessage, out1, out2, ... outM] = evalpythonfunction(fileName, pythonFunctionName, Arg1, Arg2, ..., ArgN)

Inputs

fileName
A fully qualified Python file name. Can be an empty string if function is known in Python global name space.
Type: char
Dimension: string
pythonFunctionName
Any valid Python function name.
Type: char
Dimension: string
Arg1, Arg2, ..., ArgN
Inputs argument(s) to Python function. These arguments are equal to number of arguments that the Python function accepts.
Type: Type of OML variables that can be exported to Python. Refer exporttopython Compose OML function for supported OML variable data types.

Outputs

status
Status of the script executed.
1
success
0
failure
Type: number
errorMessage
Error message indicating the failure.
Type: string
out1, out2, ... outM
Output from Python function. These are equal to number of output Python function returns.
Type: Type of Python variables which can be imported./>. Refer getpythonvar OML function for supported Python variable data types to OML data types mapping.

Example

Example 1 - evalpythonfunction example, calling function with no input arguments and no return values.


[status,errorMessage]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_1')
status = 1
errorMessage = 

Example 2 - evalpythonfunction example, calling function with input arguments and no return values.


x=9;
y=99;
[status,errorMessage]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_2',x,y)
status = 1
errorMessage = 

Example 3 - evalpythonfunction example, calling function with input arguments and return values.


x1=9;
y1=99;
[status,errorMessage,out31, out32]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_3',x1,y1)
status = 1
errorMessage = 
out31 = 18
out32 = 100

Example 4 - evalpythonfunction example, calling function with no input arguments and with return values.


[status,errorMessage,out41, out42]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_4')
status = 1
errorMessage = 
out41 = 11
out42 = 12

Example 5 - evalpythonfunction example, calling function with no input arguments and with return values.


[status,errorMessage,out51, out52]=evalpythonfunction('evalpythonfunction_test.py', 'test_call_5')
status = 1
errorMessage = 
out51 = 
{
  [1,1] 1
  [1,2] 2
  [1,3] 3
  [1,4] 4
}
out52 = test_call_4