def hsv_convert(arr):
    """ fast rgb_to_hsv using numpy array """
 
    # adapted from Arnar Flatberg
    # http://www.mail-archive.com/numpy-discussion@scipy.org/msg06147.html
    # it now handles NaN properly and mimics colorsys.rgb_to_hsv output

    #assert(arr.min()>=0 and arr.max()<=1)

    #arr = arr/255.
    arr = arr.astype("float32")
    out = np.empty_like(arr)

    arr_max = arr.max(-1)
    delta = arr.ptp(-1)
    s = delta / arr_max
    
    s[delta==0] = 0

    # red is max
    idx = (arr[:,:,0] == arr_max) 
    out[idx, 0] = (arr[idx, 1] - arr[idx, 2]) / delta[idx]

    # green is max
    idx = (arr[:,:,1] == arr_max) 
    out[idx, 0] = 2. + (arr[idx, 2] - arr[idx, 0] ) / delta[idx]

    # blue is max
    idx = (arr[:,:,2] == arr_max) 
    out[idx, 0] = 4. + (arr[idx, 0] - arr[idx, 1] ) / delta[idx]

    out[:,:,0] = 1.0 % (out[:,:,0]/6.0)
    out[:,:,1] = s
    out[:,:,2] = arr_max

    # rescale back to [0, 255]
    #out *= 255.

    # remove NaN
    out[np.isnan(out)] = 0

    return out
dataset/ETHPy150Open bolme/pyvision/src/pyvision/features/v1like.py/hsv_convert/swapped operands of `%`