imshow seems to fail on some (int16?) arrays

Hello,

I have a rather weird problem with imshow:

I’m trying to plot a grayscale (nonzero) array as an image – so it’s basically plt.imshow(array). However, this pops up (after plt.show()) a completely black image. It happens that this array has dtype=int16, and imshow’s doc says that it only accepts float arrays, though I’m pretty sure it does some conversion to allow int32s (at least, as I’ve used them before). So I tried plt.imshow(asarray(array, dtype=np.dtype(np.int32))), and it worked (the image showed up). With asfarray(array), it worked too. Now, the weirdest part was that though np.abs(array) or abs(array) (the builtin abs) still have dtype int16, they can be plotted successfully with plt.imshow too!

So I must say I’m not really sure of what’s failing here… has anyone encountered this bug before?

Thanks in advance,

Antony Lee

(Oh, and I did try plt.imshow(array+0), but this one didn’t work…)