On Sat, May 14, 2016 at 3:23 AM, Phillip Feldman < phillip.m.feld...@gmail.com> wrote:
> I often find a need to do the type of comparison done by function shown > below. I suspect that this would be more efficient for large arrays if > implemented direction in C. Is there any possibility of adding something > like this to NumPy? > > def three_way(x, y): > """ > This function performs a 3-way comparison on `x` and `y`, which must be > either lists or arrays of compatible shape. Each pair of items or > elements-- > let's call them x[i] and y[i]--are compared. The corresponding element > in > the output array is 1 if `x[i]` is greater then `y[i]`, -1 of `x[i]` is > less, > and zero if the two are equal. > """ > numpy.greater(y, x).astype(int) - numpy.less(y, x).astype(int) > isn't that the same as sign( x- y) ? Josef > > Phillip > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion