I have similar needs, but for int array and integer interval (like -32768~32767), currently I'm using bitwise and/or (&/|) to do this trick. It will be nice if there is an optimized function, both for float and int -- Sent from: http://numpy-discussion.10968.n7.nabble.com/