When creating the hessian matrix, it should be hessian_full=[[()] * ndim for x in range(ndim)] instead of hessian_full = [[None] * ndim] * ndim
When creating the hessian matrix, it should be
hessian_full=[[()] * ndim for x in range(ndim)]
instead of
hessian_full = [[None] * ndim] * ndim