¡@

Home 

python Programming Glossary: np.vectorize

Changing image hue with Python PIL

http://stackoverflow.com/questions/7274221/changing-image-hue-with-python-pil

import Image import numpy as np import colorsys rgb_to_hsv np.vectorize colorsys.rgb_to_hsv hsv_to_rgb np.vectorize colorsys.hsv_to_rgb.. rgb_to_hsv np.vectorize colorsys.rgb_to_hsv hsv_to_rgb np.vectorize colorsys.hsv_to_rgb def shift_hue arr hout r g b a np.rollaxis.. in the standard library . My first attempt used rgb_to_hsv np.vectorize colorsys.rgb_to_hsv hsv_to_rgb np.vectorize colorsys.hsv_to_rgb..

Function application over numpy's matrix row/column

http://stackoverflow.com/questions/8079061/function-application-over-numpys-matrix-row-column

function to get more concrete advice. Numpy provides np.vectorize and np.frompyfunc to turn Python functions which operate on.. def myfunc a b if a b return a else return b vecfunc np.vectorize myfunc result vecfunc 1 2 3 5 6 9 7 4 5 print result # 7 4 5.. array when the second is bigger. But don't get too excited np.vectorize and np.frompyfunc are just syntactic sugar . They don't actually..