Take values and transmute them into a new range
199727
def _scale_y_values(self, values, new_min, new_max, scale_old_from_zero=True):
        '''
        
        '''
        # Scale Y values - Create a scaled list of values to use for the visual graph
        scaled_values = []
        y_min_value = min(values)
        if scale_old_from_zero:
            y_min_value = 0
        y_max_value = max(values)
        new_min = 0
        OldRange = (y_max_value - y_min_value) or 1  # Prevents division by zero if all values are the same
        NewRange = (new_max - new_min)  # max_height is new_max
        for old_value in values:
            new_value = (((old_value - y_min_value) * NewRange) / OldRange) + new_min
            scaled_values.append(new_value)
        return scaled_values
482259
function swap(values, boxes, indices, i, j) {
    const temp = values[i];
    values[i] = values[j];
    values[j] = temp;

    const k = 4 * i;
    const m = 4 * j;

    const a = boxes[k];
    const b = boxes[k + 1];
    const c = boxes[k + 2];
    const d = boxes[k + 3];
    boxes[k] = boxes[m];
    boxes[k + 1] = boxes[m + 1];
    boxes[k + 2] = boxes[m + 2];
    boxes[k + 3] = boxes[m + 3];
    boxes[m] = a;
    boxes[m + 1] = b;
    boxes[m + 2] = c;
    boxes[m + 3] = d;

    const e = indices[i];
    indices[i] = indices[j];
    indices[j] = e;
}
1356381
private static void reverseRange(Object[] a, int lo, int hi) {
        hi--;
        while (lo < hi) {
            Object t = a[lo];
            a[lo++] = a[hi];
            a[hi--] = t;
        }
    }
480525
def range(start, finish, step):
        """"""
        value = start
        while value <= finish:
            yield value
            value += step
215660
def _combine_ranges_on_length(self, data_len, first, second):
        '''
        
        '''
        first = get_true_slice(first, data_len)
        second = get_true_slice(second, data_len)
        final_start, final_step, final_stop = (None, None, None)

        # Get our start
        if first.start == None and second.start == None:
            final_start = None
        else:
            final_start = (first.start if first.start else 0)+(second.start if second.start else 0)

        # Get our stop
        if second.stop == None:
            final_stop = first.stop
        elif first.stop == None:
            final_stop = (first.start if first.start else 0) + second.stop
        else:
            final_stop = min(first.stop, (first.start if first.start else 0) + second.stop)

        # Get our step
        if first.step == None and second.step == None:
            final_step = None
        else:
            final_step = (first.step if first.step else 1)*(second.step if second.step else 1)

        # If we have a start above our stop, set them to be equal
        if final_start > final_stop:
            final_start = final_stop

        return slice(final_start, final_stop, final_step)
1319936
def _order_as_range(order):
    """"""
    order = order.split('-')
    order = [int(o) for o in order]
    if len(order) > 1:
        order = range(order[0], (order[-1] + 1))
    return order
553556
def _flatten(v, val):
    """"""
    if isinstance(v, Variable):
        yield v, int(val)
    else:
        if len(v) != len(val):
            raise ValueError("expected 1:1 mapping from Variable => {0, 1}")
        for _var, _val in zip(v, val):
            yield from _flatten(_var, _val)
211137
def rangify(number_list):
    """"""
    if not number_list:
        return number_list

    ranges = []

    range_start = prev_num = number_list[0]
    for num in number_list[1:]:
        if num != (prev_num + 1):
            ranges.append((range_start, prev_num))
            range_start = num
        prev_num = num

    ranges.append((range_start, prev_num))
    return ranges
657207
def _to_value(self, current, target, max_steps, step_down, step_up):
        
        for _ in range(steps(current, target, max_steps)):
            if (current - target) > 0:
                step_down()
            else:
                step_up()
790599
function toSingleRule(str) {

  return str
    // replace modulus with shortcuts
    .replace(/([nivwft]) % (\d+)/g, '$1$2')
    // replace ranges
    .replace(/([nivwft]\d*) (=|\!=) (\d+[.,][.,\d]+)/g, function (match, v, cond, range) {
      // range = 5,8,9 (simple set)
      if (range.indexOf('..') < 0 && range.indexOf(',') >= 0) {
        if (cond === '=') {
          return format('IN([ %s ], %s)', range.split(',').join(', '), v);
        }
        return format('!IN([ %s ], %s)', range.split(',').join(', '), v);
      }
      // range = 0..5 or 0..5,8..20 or 0..5,8
      var conditions = range.split(',').map(function (interval) {
        // simple value
        if (interval.indexOf('..') < 0) {
          return format('%s %s %s', v, cond, interval);
        }
        // range
        var start = interval.split('..')[0],
            end   = interval.split('..')[1];
        if (cond === '=') {
          return format('B(%s, %s, %s)', start, end, v);
        }
        return format('!B(%s, %s, %s)', start, end, v);
      });

      var joined;
      if (conditions.length > 1) {
        joined =  '(' + conditions.join(cond === '=' ? ' || ' : ' && ') + ')';
      } else {
        joined = conditions[0];
      }
      return joined;
    })
    .replace(/ = /g, ' === ')
    .replace(/ != /g, ' !== ')
    .replace(/ or /g, ' || ')
    .replace(/ and /g, ' && ');
}
437741
def replace (inlst,oldval,newval):
    
    lst = inlst*1
    for i in range(len(lst)):
        if type(lst[i]) not in [ListType,TupleType]:
            if lst[i]==oldval: lst[i]=newval
        else:
            lst[i] = replace(lst[i],oldval,newval)
    return lst
434507
def map(value, v_min, v_max, d_min, d_max)
      v_value = value.to_f # so it returns float

      v_range = v_max - v_min
      d_range = d_max - d_min
      (v_value - v_min) * d_range / v_range + d_min
    end
399936
def convert(self, values, nan_rep, encoding, errors):
        

        self.values = Int64Index(np.arange(self.table.nrows))
        return self
1194245
function rangeStep(start, end, step) {
  let num = new Decimal(start);
  const result = [];

  while (num.lt(end)) {
    result.push(num.toNumber());

    num = num.add(step);
  }

  return result;
}
733116
function range(begin, end, interval = 1) {
  var a = [];

  for (let i = begin; i < (begin+end); i += interval) {
    a.push(i);
  }

  return a;
}
266710
def transform(self, offset):
        
        assert self._start + offset > 0, \
            ('offset {} invalid; resulting range [{}, {}) is '
             'undefined'.format(offset, self._start+offset, self._end+offset))
        self._start += offset
        self._end += offset
1327023
def MakeRanges(codes):
  """"""
  ranges = []
  last = -100
  for c in codes:
    if c == last+1:
      ranges[-1][1] = c
    else:
      ranges.append([c, c])
    last = c
  return ranges