docs: def nice_indices(arr):
      '''
      takes an array like [1,1,5,5,5,999,1,1]
      and maps to something like [0,0,1,1,1,2,0,0]
      modifies original in place as well as returns a ref
      '''
      # surprisingly, this is slower for very small (and very large) inputs:
      # u,f,i = np.unique(arr,return_index=True,return_inverse=True)
      # arr[:] = np.arange(u.shape[0])[np.argsort(f)][i]
      ids = collections.defaultdict(count().__next__)
      for idx,x in enumerate(arr):
          arr[idx] = ids[x]
      return arr