Numpy vectorize and atomic vectors
问题 I would like to implement a function that works like the numpy.sum function on arrays as on expects, e.g. np.sum([2,3],1) = [3,4] and np.sum([1,2],[3,4]) = [4,6]. Yet a trivial test implementation already behaves somehow awkward: import numpy as np def triv(a, b): return a, b triv_vec = np.vectorize(fun, otypes = [np.int]) triv_vec([1,2],[3,4]) with result: array([0, 0]) rather than the desired result: array([[1,3], [2,4]]) Any ideas, what is going on here? Thx 回答1: You need otypes=[np.int,np