On Fri, Feb 8, 2013 at 3:54 PM, Daπid <davidmen...@gmail.com> wrote:
> TypeError: Cannot cast array data from dtype('uint16') to > dtype('uint8') according to the rule 'safe'. > That really makes it sound like the check is being done the other way around! But I'd be surprised if something so obvious hadn't been seen and reported earlier, especially since I have tried it on a Linux box with older versions, and things were the same in 1.2.1. So that means this would be a 5 year old bug. >>> np.__version__ '1.2.1' >>> lut = np.random.randint(256, size=(65536,)).astype('uint8') >>> arr = np.random.randint(65536, size=(1000, 1000)).astype('uint16') >>> np.take(lut, arr) array([[ 56, 131, 248, ..., 233, 34, 191], [229, 217, 233, ..., 183, 8, 86], [249, 238, 79, ..., 38, 17, 72], ..., [ 19, 95, 199, ..., 236, 148, 39], [178, 129, 208, ..., 76, 46, 125], [ 66, 196, 71, ..., 227, 252, 94]], dtype=uint8) >>> np.take(lut, arr, out=arr) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/dist-packages/numpy/core/fromnumeric.py", line 97, in take return take(indices, axis, out, mode) TypeError: array cannot be safely cast to required type
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion