Good morning everyone,
I am trying to integrate a Python function with NIntegrate[ ].
In general, to evaluate a Python function from Mathematica, I evaluate the independent variable of the function into a number, convert the number to a string and then call the Python function, as happens in the code below, see (*example of call*):
The problem arises into NIntegrate[ ] which apparently is not passing to externalF[ ] a number but still a symbolic variable x which is then given to Python as a string of value 'x', and thus rising the error.
I tried the "SymbolicProcessing" -> False option but it did not help. Any help would be greatly appreciated!
EDIT: I appended ?NumericQ as:
externalF[u_?NumericQ] :=
ExternalEvaluate[session,
"special.ellip_harm(1,2,1,2," <> ToString[u] <>
")"]
and now the following integration is working (I compared it with Python integration):
NIntegrate[externalF[x], {x, 0.5, 1}]
Are there downsides in doing this?