I would suggest using the VoxelCoefficient function to convert numpy arrays and then interpolate it into a GridFunction (if necessary)
Code:
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
nx = 5
ny = 10
values = np.array([(sin(x) + cos(y)) for y in np.linspace(0,2*np.pi,ny) for x in np.linspace(0,2*np.pi, nx)])
values = values.reshape(nx,ny)
func = VoxelCoefficient((0,0), (1,1), values, linear=True)
H = H1(mesh, order=2)
gfu = GridFunction(H)
gfu.Set(func)
Draw(func, mesh, "func")
Draw(gfu, mesh, "gfu")