def add_at(arr, ind, vals):
 if hasattr(np.ufunc, 'at'):
  return np.add.at(arr, ind, vals)
 else:
  warnings.warn('Using slow replacement for numpy.add.at(). For ~100x faster results update to numpy 1.8+')
  arr = np.asarray(arr)
  (ind, vals) = np.broadcast_arrays(ind, vals)
  unq = np.unique(ind)
  arr[unq] += [vals[(ind == i)].sum() for i in unq]

def add_at ( arr , ind , vals ) : if hasattr ( np . ufunc , 'at' ) : return np . add . at ( arr , ind , vals ) else : warnings . warn ( 'Using slow replacement for numpy.add.at(). For ~100x faster results update to numpy 1.8+' ) arr = np . asarray ( arr ) ( ind , vals ) = np . broadcast_arrays ( ind , vals ) unq = np . unique ( ind ) arr [ unq ] += [ vals [ ( ind == i ) ] . sum ( ) for i in unq ]
utility that computes np .