I'm using the package numddifftools to calculate the hessians of a multidimensional function (from R^n to R^n). While changing the code to use numpy arrays instead of lists, I discovered that doing so broke the code. Specifically:
import numpy as np 
import numdifftools as nd
def function(x):
    out = np.zeros(2)
    out[0] = x[0] - x[1]**2/2.0
    return float(out[0])
tempHessian = nd.Hessian(function, method='complex')
tempHessian([0.4,0.4])
Produces the error: ...\Continuum\Anaconda3\lib\site-packages\ipykernel_launcher.py:8: ComplexWarning: Casting complex values to real discards the imaginary part
and gives a zero hessian.
However, this one works fine:
import numpy as np 
import numdifftools as nd
def function(x):
    return x[0] - x[1]**2/2.0
tempHessian = nd.Hessian(function, method='complex')
tempHessian([0.4,0.4])
Any ideas what could be the problem? Thanks!
 
    