Transform value +x+ according to domain and range
359111
def scale(x)
      return nil if x.nil?
      x=x.to_f
      j=Rubyvis.search(@d, x)
      j=-j-2 if (j<0)
      j=[0,[@i.size-1,j].min].max
      # p @l
      # puts "Primero #{j}: #{@f.call(x) - @l[j]}"
      # puts "Segundo #{(@l[j + 1] - @l[j])}"
      @i[j].call((@f.call(x) - @l[j]) .quo(@l[j + 1] - @l[j]));
    end
742455
function rangeExtents(ranges) {
  var start = Number.MAX_VALUE;
  var end = Number.MIN_VALUE;
  ranges.map(function (_ref) {
    var rs = _ref.start,
        re = _ref.end;

    start = Math.min(start, rs);
    end = Math.max(end, re);
  });
  return { start: start, end: end };
}
1138085
def _call(self, x, out=None):
        """"""
        if out is None:
            return self.range.element(copy(self.constant))
        else:
            out.assign(self.constant)
895731
def normalize_to_range(
    values,
    minimum = 0.0,
    maximum = 1.0
    ):

    

    normalized_values = []
    minimum_value = min(values)
    maximum_value = max(values)
    for value in values:
        numerator = value - minimum_value
        denominator = maximum_value - minimum_value
        value_normalized = (maximum - minimum) * numerator/denominator + minimum
        normalized_values.append(value_normalized)
    return normalized_values
650577
def set_range_x(self,val):
        
        d = self.declaration
        if d.auto_range[0]:
            return
        self.widget.setXRange(*val,padding=0)
704665
function expandXBounds(bounds, value) {
  if (bounds[MIN_X] > value) bounds[MIN_X] = value;else if (bounds[MAX_X] < value) bounds[MAX_X] = value;
}
642199
def within_range(range1, range2):
    """"""
    range1 = [r if isfinite(r) else None for r in range1]
    range2 = [r if isfinite(r) else None for r in range2]
    return ((range1[0] is None or range2[0] is None or range1[0] >= range2[0]) and
            (range1[1] is None or range2[1] is None or range1[1] <= range2[1]))
500177
public function interpolate( $x )
	{
		$sum	= 0;
		$values	= array_values( $this->data );
		$expressions	= $this->getExpressions();
		for( $i=0; $i<count( $expressions ); $i++ )
		{
			$expression	= $expressions[$i];
			$formula	= new Alg_Math_Formula( $expression, array( "x" ) );
			$value	= $formula->getValue( 2 );
			$sum	+= $values[$i] * $value;
		}
		return $sum;
	}
924829
def normalize(x, min_value, max_value):
    """"""
    x = (x - min_value) / (max_value - min_value)
    return clip(x, 0, 1)
740076
def xrange(self, stream, start='-', stop='+', count=None):
        """"""
        if count is not None:
            extra = ['COUNT', count]
        else:
            extra = []
        fut = self.execute(b'XRANGE', stream, start, stop, *extra)
        return wait_convert(fut, parse_messages)
1095587
function inRange (value, min, max) {
  const int = parseInt(value, 10)

  return (
    `${int}` === `${value.replace(/^0/, '')}` &&
    int >= min &&
    int <= max
  )
}
414426
function decodeAndClamp(value, addend, coefficient, max) {
    value = addend + value * coefficient;
    // Clamp the value to the range
    return (value < 0 ? 0 : (value > max ? max : value));
  }
1111325
def stretch(from = 0 .. 0xFF, to = 0 .. 0xFF)
      if from.exclude_end?
        raise "Stretching does not support ranges with end value " +
              "excluded (such as #{from})"
      end
      if to.exclude_end?
        raise "Stretching does not support ranges with end value " +
              "excluded (such as #{to})"
      end
      if from.last != from.first
        factor = (to.last - to.first).to_f / (from.last - from.first)
        collect { |x| ((x - from.first) * factor).major(to.first).minor to.last }
      else
        (self <= from.first).conditional to.first, to.last
      end
    end
130380
def _transform(self, value):
        
        if self.transform:
            try:
                value = self.transform(value)
            except:
                import sys
                exc_type, exc_obj, exc_tb = sys.exc_info()
                raise AssertionError('Error applying transformation <{0}>: {2}: {3}'.format(
                    self.transform.__name__, value, exc_type.__name__, exc_obj))

        return value
1350742
def round(self, value_array):
        

        min_value = self.domain[0]
        max_value = self.domain[1]

        rounded_value = value_array[0]
        if rounded_value < min_value:
            rounded_value = min_value
        elif rounded_value > max_value:
            rounded_value = max_value

        return [rounded_value]
667602
def transform(self, X):
        

        for col in range(X.shape[1]):
            X[:, col] = self._transform_col(X[:, col], col)

        return X
948367
def p_expr_plus(self, tree):
        ''' '''
        tree.value = convertstr(tree[0].value) + convertstr(tree[2].value)