def normalize_array(a,direction="column"):
    """
    Normalizes an array to sum to one, either column wise, 
    or row wise or the full array.
    
    *Directions*
        Column-wise - 0 default
        Row-wise - 1 default
        All - 2 default
    """
    b = a.copy()
    if(direction == "column"):
        sums = np.sum(b,0)
        return np.nan_to_num(sums/b)
    elif(direction == "row"):
        sums =np.sum(b,1)
        return  np.nan_to_num((b.transpose() / sums).transpose())
    elif(direction == "all"):
        sums = np.sum(b)
        return np.nan_to_num(b / sums)
    else:
        print "Error non existing normalization"
        return b
dataset/ETHPy150Open alvations/pywsd/merlin/utils.py/normalize_array/swapped operands of `/`