Get the most similar matching item from a list of items.

    @param base: base item to locate best match
    @param items: list of items for comparison
    @return: most similar matching item or None
961279
def match_similar(base, items):
    
    finds = list(find_similar(base, items))
    if finds:
        return max(finds, key=base.similarity)  # TODO: make O(n)

    return None
1317361
def similar_objects(self, num=None, **filters):
        
        # TODO: filter appsettings.FLUENT_BLOGS_FILTER_SITE_ID:
        #    filters.setdefault('parent_site', self.parent_site_id)

        # FIXME: Using super() doesn't work, calling directly.
        return TagsMixin.similar_objects(self, num=num, **filters)
1216280
def infer_list_subtype(items):
        """"""
        subtype = End

        for item in items:
            item_type = type(item)
            if not issubclass(item_type, Base):
                continue

            if subtype is End:
                subtype = item_type
                if not issubclass(subtype, List):
                    return subtype
            elif subtype is not item_type:
                stype, itype = subtype, item_type
                generic = List
                while issubclass(stype, List) and issubclass(itype, List):
                    stype, itype = stype.subtype, itype.subtype
                    generic = List[generic]

                if stype is End:
                    subtype = item_type
                elif itype is not End:
                    return generic.subtype
        return subtype
980237
public T match(Collection<I> items)
    {
        for (I item : items)
        {
            T match = match(item);
            if (match != null)
            {
                return match;
            }
        }
        return null;
    }
1065308
def equal(list1, list2):
    
    return [item1 == item2 for item1, item2 in broadcast_zip(list1, list2)]
87244
public boolean matches(ESigItem item) {
        if (selected != null && item.isSelected() != selected) {
            return false;
        }
        
        if (eSigType != null && !item.getESigType().equals(eSigType)) {
            return false;
        }
        
        if (session != null && !item.getSession().equals(session)) {
            return false;
        }
        
        if (ids != null && !ids.contains(item.getId())) {
            return false;
        }
        
        return true;
    }
1061096
@SuppressWarnings({"unchecked"})
    public final boolean matches(Object item) {
        return item != null
                && expectedType.isInstance(item)
                && matchesSafely((T) item);
    }
47609
def similar_items(self, itemid, N=10):
        
        if itemid >= self.similarity.shape[0]:
            return []

        return sorted(list(nonzeros(self.similarity, itemid)), key=lambda x: -x[1])[:N]
1091229
def sorted_bases(bases):
    '''
    '''
    ret = []

    for base in bases:
        # lst = [super(base), super(super(base)), ..., highest_base]
        lst = _bases(base)

        if not ret:
            ret = lst
        elif not any(b in ret for b in lst):
            ret += lst
        else:
            buf = []
            for b in lst:
                if b in ret:
                    if buf:
                        ret = graft(ret, buf, ret.index(b))
                        buf = []
                else:
                    buf.append(b)
            if buf:
                ret += buf

    return ret
1246654
def items(cls):
        
        items = [(value.name, key) for key, value in cls.values.items()]
        return sorted(items, key=lambda x: x[1])
979681
def get_items_as_list(items,keys,items_names='styles'):
	
	if type(items)!=dict:
		if type(items)==list:
			if len(items)!=len(keys):
				raise Exception('List of {0} is not the same length as keys'.format(items_names))
			else:
				items=dict(zip(keys,items))
		else:
			items=dict(zip(keys,[items]*len(keys)))
	return items
1089614
def _duplicates(list_):
    """"""
    item_indices = {}
    for i, item in enumerate(list_):
        try:
            item_indices[item].append(i)
        except KeyError:  # First time seen
            item_indices[item] = [i]
    return item_indices
1170350
def best_item_from_list(item,options,fuzzy=90,fname_match=True,fuzzy_fragment=None,guess=False):
    ''''''
    match = best_match_from_list(item,options,fuzzy,fname_match,fuzzy_fragment,guess)
    if match:
        return match[0]
    return None
200191
def _put_many(self, items):
        ''' 
        '''
        for item in items:
            if not isinstance(item, self._item_class):
                raise RuntimeError('Items mismatch for %s and %s' % (self._item_class, type(item)))
            self._put_one(item)
212522
def similar(obj1, obj2):
    """"""
    Comparable.log(obj1, obj2, '%')
    similarity = obj1.similarity(obj2)
    Comparable.log(obj1, obj2, '%', result=similarity)
    return similarity
304797
private <T> T getItem(String itemName, Map<String, T> items, String typeName) {
		T item = items.get(itemName);
		if (item == null) {
			throw new FuzzerException(name + ": " + typeName + " '" + itemName + "' not found");
		}
		return item;
	}
648320
def items_sort(cls, items):
        
        class t(tuple):
            """Tuple with element-based sorting"""
            def __cmp__(self, other):
                for a, b in six.moves.zip_longest(self, other):
                    if a != b:
                        if a is None:
                            return 1
                        if b is None:
                            return -1
                        return a - b
                return 0

            def __lt__(self, other):
                return self.__cmp__(other) < 0
            def __gt_(self, other):
                return self.__cmp__(other) > 0
            def __le__(self, other):
                return self.__cmp__(other) <= 0
            def __ge_(self, other):
                return self.__cmp__(other) >= 0
            def __eq__(self, other):
                return self.__cmp__(other) == 0
            def __ne__(self, other):
                return self.__cmp__(other) != 0

        def key_func(x):
            if x.indented:
                return t((int(x.parent_item.sort), int(x.sort)))
            return t((int(x.sort), ))

        return sorted(items, key=key_func, reverse=True)