r'''
Merge bins with right-neighbour until each bin has a minimum width.

:arguments:

  **bins** (``<array_like>``)
    The bin-edges.

  **min_width** (``<float>``)
    The minimum bin width.

def histogram_bin_edges_minwidth(min_width, bins):
  r'''
Merge bins with right-neighbour until each bin has a minimum width.

:arguments:

  **bins** (``<array_like>``)
    The bin-edges.

  **min_width** (``<float>``)
    The minimum bin width.
  '''

  # escape
  if min_width is None : return bins
  if min_width is False: return bins

  # keep removing where needed
  while True:

    idx = np.where(np.diff(bins) < min_width)[0]

    if len(idx) == 0: return bins

    idx = idx[0]

    if idx+1 == len(bins)-1: bins = np.hstack(( bins[:(idx)  ], bins[-1]       ))
    else                   : bins = np.hstack(( bins[:(idx+1)], bins[(idx+2):] ))