Return the index in arr of the closest float value to val.
331353
def indexOfClosest( arr, val ):
    ''''''
    i_closest = None
    for i,v in enumerate(arr):
        d = math.fabs( v - val )
        if i_closest == None or d < d_closest:
            i_closest = i
            d_closest = d
    return i_closest
52608
def get_float(self, key, default=None):
        
        value = self.get(key, default)
        return None if value is None else float(value)
1082308
def value(self):
        
        if self.opts['int']:
            return int(self.val)
        else:
            return float(self.val)
185360
def get_value(self, index):
        """"""
        if index.column() == 0:
            return self.keys[ index.row() ]
        elif index.column() == 1:
            return self.types[ index.row() ]
        elif index.column() == 2:
            return self.sizes[ index.row() ]
        else:
            return self._data[ self.keys[index.row()] ]
269601
function singleIndexOf(arr, v) {
  var pos = -1;
  var i, l;
  if (!arr) {
    return -1;
  }
  for (i = 0, l = arr.length; i < l; i++) {
    if (arr[i] === v) {
      if (pos >= 0) {
        return -2;
      }
      pos = i;
    }
  }
  return pos;
}
643498
public float getFloat(int index, float def) {
        Object tmp = mArray.get(index);
        return tmp != null && tmp instanceof Number ? ((Number) tmp)
                .floatValue() : def;
    }
9178
def valarray(shape, value=np.NaN, typecode=None):
    """"""
    if typecode is None:
        typecode = bool
    out = np.ones(shape, dtype=typecode) * value

    if not isinstance(out, np.ndarray):
        out = np.asarray(out)
    return out
1095980
def _index_of(arr, lookup):
    
    # Equivalent of np.digitize(arr, lookup) - 1, but much faster.
    # TODO: assertions to disable in production for performance reasons.
    # TODO: np.searchsorted(lookup, arr) is faster on small arrays with large
    # values
    lookup = np.asarray(lookup, dtype=np.int32)
    m = (lookup.max() if len(lookup) else 0) + 1
    tmp = np.zeros(m + 1, dtype=np.int)
    # Ensure that -1 values are kept.
    tmp[-1] = -1
    if len(lookup):
        tmp[lookup] = np.arange(len(lookup))
    return tmp[arr]
135121
def minValue(self, value):
        """"""
        if isinstance(value, [int, float, long]):
            self._rangeMin = value
943963
public Object getValue(int x) {
    if (x >= width())
      throw new IllegalArgumentException("Index out of scope on axis (" + x + " >= " + width() + ")!");

    return m_Min + m_Step*x;
  }
294380
function findValue (arr, value) {
	value = purifyValue(value);

	for (var i = arr.length - 1; i >= 0; i--) {
		if (arr[i].val === value) {
			return arr[i].pos;
		};

		if (i === 0) {
			return -1;
		};
	};
}
1287902
function pullByIndex(arr, index) {
    if (index < arr.length) {
        const value = arr[index];
        shift(arr, index);
        return value;
    }

    return undefined;
}
425928
function (index) {
      // Get the closest top fraction.
      var fraction = Math.ceil(index % 1 * this.options.fractions) / this.options.fractions;
      // Truncate decimal trying to avoid float precission issues.
      var p = Math.pow(10, this.options.scale);
      return Math.floor(index) + Math.floor(fraction * p) / p;
    }
873946
def inv(x):
    '''
    
    '''
    if sps.issparse(x): return 1.0 / x.toarray()        
    else:               return 1.0 / np.asarray(x)
788376
function closestToZero(numbers, maxNumber) {
    //returns the index of value closest to 0
    var positiveNumbers = numbers.map(function(number) {
        return Math.abs(number);
    });

    var sortedPositiveNumbers = positiveNumbers.sort(function(a, b) {
        return (a - b);
    });

    return sortedPositiveNumbers[0];
}
476887
def nearest(self, idx):
        """"""
        hi = self.after(idx)
        lo = self.before(idx)
        if hi is None:
            return lo
        if lo is None:
            return hi
        if abs(hi - idx) < abs(lo - idx):
            return hi
        return lo
1090546
def closestDirectDistance(arr, ksize=30, dtype=np.uint16):
    '''
    
    '''

    out = np.zeros_like(arr, dtype=dtype)
    _calc(out, arr, ksize)
    return out