I'm trying to build a meshgrid with small nonnegative integers default is int32
>>> np.meshgrid([0,1,2], [0,1])[0].dtype dtype('int32') If I use uint, then the arrays are upcast to int64 - Why? >>> np.meshgrid(np.array([0,1,2], np.uint), np.array([0,1], np.uint))[0].dtype dtype('int64') broadcast_arrays preserves dtype >>> np.broadcast_arrays(np.array([0,1,2], np.uint)[:,None], np.array([0,1], np.uint)[None, :]) [array([[0, 0], [1, 1], [2, 2]], dtype=uint32), array([[0, 1], [0, 1], [0, 1]], dtype=uint32)] with uint8 >>> np.broadcast_arrays(np.array([0,1,2], np.uint8)[:,None], np.array([0,1], np.uint8)[None, :]) [array([[0, 0], [1, 1], [2, 2]], dtype=uint8), array([[0, 1], [0, 1], [0, 1]], dtype=uint8)] >>> np.meshgrid(np.array([0,1,2], np.uint8), np.array([0,1], np.uint8))[0].dtype dtype('int32') >>> Winpython 64 bit >>> np.__version__ '1.9.2rc1' Josef
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion