def changed_locations(a, include_first):
 if (a.ndim > 1):
  raise ValueError('indices_of_changed_values only supports 1D arrays.')
 indices = (flatnonzero(diff(a)) + 1)
 if (not include_first):
  return indices
 return hstack([[0], indices])

def changed_locations ( a , include_first ) : if ( a . ndim > 1 ) : raise ValueError ( 'indices_of_changed_values only supports 1D arrays.' ) indices = ( flatnonzero ( diff ( a ) ) + 1 ) if ( not include_first ) : return indices return hstack ( [ [ 0 ] , indices ] )
compute indices of values in a that differ from the previous value .