Return the score for item x (cheap lookup), Item 0 is always the best item
960952
def score(self, i):
        """"""
        if self.minimize:
            return self.data[i][0]
        else:
            return self.data[(-1 * i) - 1][0]
545139
function getItemDepth(opts: Options, value: Value, block?: Block): number {
    const { document, startBlock } = value;
    block = block || startBlock;

    const currentItem = getCurrentItem(opts, value, block);
    if (!currentItem) {
        return 0;
    }

    const list = document.getParent(currentItem.key);

    return 1 + getItemDepth(opts, value, list);
}
1249433
def _dict_lookup(cls, item, **kwargs):
        '''
        
        '''
        log.debug('item == %s', item)
        value_lookup = kwargs.get('value_lookup', False)
        if 'lookup' in kwargs:
            for k, v in six.iteritems(kwargs['lookup']):
                if value_lookup:
                    if six.text_type(v).lower() == six.text_type(item).lower():
                        log.debug('returning key %s', k)
                        return k
                else:
                    if six.text_type(k).lower() == six.text_type(item).lower():
                        log.debug('returning value %s', v)
                        return v
        return 'Invalid Value'
1094427
def folderitem(self, obj, item, index):
        
        url = item.get("url")
        title = item.get("Title")

        item["getDownFrom"] = self.localize_date(obj.getDownFrom())
        item["getDownTo"] = self.localize_date(obj.getDownTo())
        item["getValidator"] = obj.getValidator()
        item["replace"]["Title"] = get_link(url, value=title)

        # validation with the most remaining days
        if obj == self.latest_validation:
            item["state_class"] = "state-published"
        # running validations
        elif obj in self.active_validations:
            item["state_class"] = "state-active"
        # inactive validations
        else:
            item["state_class"] = "state-inactive"

        return item
1363194
def _objective_bestscore(self, old, new):
        
        (oldscore, oldthing) = old
        (newscore, newthing) = new
        if oldscore is None:
            return True
        if newscore is None:
            return False
        return oldscore < newscore
112198
function findBestMatchingIndex(selector, userFields, sortOrder, indexes) {

  var matchingIndexes = findMatchingIndexes(selector, userFields, sortOrder, indexes);

  if (matchingIndexes.length === 0) {
    //return `all_docs` as a default index;
    //I'm assuming that _all_docs is always first
    var defaultIndex = indexes[0];
    defaultIndex.defaultUsed = true;
    return defaultIndex;
  }
  if (matchingIndexes.length === 1) {
    return matchingIndexes[0];
  }

  var userFieldsMap = utils.arrayToObject(userFields);

  function scoreIndex(index) {
    var indexFields = index.def.fields.map(getKey);
    var score = 0;
    for (var i = 0, len = indexFields.length; i < len; i++) {
      var indexField = indexFields[i];
      if (userFieldsMap[indexField]) {
        score++;
      }
    }
    return score;
  }

  return utils.max(matchingIndexes, scoreIndex);
}
215318
public String getItem(String itemName, String suffix) {
        return items.get(lookupItemName(itemName, suffix, false));
    }
501772
def rank_items(self, userid, user_items, selected_items, recalculate_user=False):
        
        # check if selected_items contains itemids that are not in the model(user_items)
        if max(selected_items) >= user_items.shape[1] or min(selected_items) < 0:
            raise IndexError("Some of selected itemids are not in the model")

        # calculate the relevance scores
        liked_vector = user_items[userid]
        recommendations = liked_vector.dot(self.similarity)

        # remove items that are not in the selected_items
        best = sorted(zip(recommendations.indices, recommendations.data), key=lambda x: -x[1])
        ret = [rec for rec in best if rec[0] in selected_items]

        # returned items should be equal to input selected items
        for itemid in selected_items:
            if itemid not in recommendations.indices:
                ret.append((itemid, -1.0))
        return ret
526163
def find_gt(self, item):
        ''
        k = self._key(item)
        i = bisect_right(self._keys, k)
        if i != len(self):
            return self._items[i]
        raise ValueError('No item found with key above: %r' % (k,))
731843
function(ary, item, i, l) {
        if (ary.indexOf) return ary.indexOf(item)
        for (i = 0, l = ary.length; i < l; i++) if (ary[i] === item) return i
        return -1
    }
1331951
function findAllIndices(needle = mandatory(), haystack = mandatory()) {
  var indices = [];
  for (var i = 0; i < haystack.length; i++) {
    if (haystack.substr(i, needle.length) === needle) {
      indices.push(i);
    }
  }

  if (indices.length) {
    return indices;
  } else {
    return -1;
  }
}
354483
def _index(self, item):
        ''''''
        index = bisect.bisect_left(self._members, item)
        if index != len(self) and self._members[index] == item:
            return index

        return -1
1255497
def toDict(self):
        
        result = _Base.toDict(self)
        result['score'] = self.score.score
        return result
1337234
def getitem(lst, indices):
    
    if not indices:
        return lst

    i, indices = indices[0], indices[1:]
    item = list.__getitem__(lst, i)

    if isinstance(i, int):
        return getitem(item, indices)

    # Empty slice: check if all subsequent indices are in range for the
    # full slice, raise IndexError otherwise. This is NumPy's behavior.
    if not item:
        if lst:
           _ = getitem(lst, (slice(None),) + indices)
        elif any(isinstance(k, int) for k in indices):
           raise IndexError
        return []

    return [getitem(x, indices) for x in item]
799377
def get_value(self, item, default=None):
        """"""
        try:
            return self[item].value
        except (AttributeError, KeyError) as e:
            return default
1234541
def get_value(self, column=0, row=0):
        
        x = self._widget.item(row, column)

        if x==None: return x
        else:       return str(self._widget.item(row,column).text())
522388
public int findItemOnlyIdx(JQMListItem item) {
        if (item == null) return -1;
        List<JQMListItem> items = getItems();
        if (items == null) return -1;
        int i = items.indexOf(item);
        if (i == -1) return -1;
        int j = 0;
        for (JQMListItem k : items) {
            if (k == null) continue;
            if (k == item) return j;
            j++;
        }
        return -1;
    }