Get an iterator of items similar but not equal to the base.

    @param base: base item to perform comparison against
    @param items: list of items to compare to the base
    @return: generator of items sorted by similarity to the base
11347
def duplicates(base, items):
    
    for item in items:
        if item.similarity(base) and not item.equality(base):
            yield item
626002
def get_banks_by_item(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.ResourceBinSession.get_bins_by_resource
        catalogs = self._get_provider_session('item_bank_session').get_banks_by_item(*args, **kwargs)
        cat_list = []
        for cat in catalogs:
            cat_list.append(Bank(self._provider_manager, cat, self._runtime, self._proxy))
        return BankList(cat_list)
1074754
def difference(self, *iterables):
        
        diff = self._set.difference(*iterables)
        return self._fromset(diff, key=self._key)
251614
def new(self, items:Iterator, processor:PreProcessors=None, **kwargs)->'ItemList':
        ""
        processor = ifnone(processor, self.processor)
        copy_d = {o:getattr(self,o) for o in self.copy_new}
        kwargs = {**copy_d, **kwargs}
        return self.__class__(items=items, processor=processor, **kwargs)
531297
@Nonnull
    public static <T> List<T> join(@Nonnull Collection<? extends T>... items) {
        int size = 0;
        for (Collection<? extends T> item : items)
            size += item.size();
        List<T> r = new ArrayList<>(size);
        for (Collection<? extends T> item : items)
            r.addAll(item);
        return r;
    }
1209980
def is_list_of_dict_like(obj, attr=('keys', 'items')):
    
    try:
        if len(obj) == 0:
            return False
        return all([is_dict_like(i, attr) for i in obj])
    except Exception:
        return False
563087
def vector_similarity(self, vector, items):
        """"""
        vector = self.normalize(vector)
        items_vec = np.stack([self.norm_vectors[self.items[x]] for x in items])
        return vector.dot(items_vec.T)
543662
def issuperset(self, items):
        
        return all(_compat.map(self._seen.__contains__, items))
280309
public static <T> Matcher<Iterable<T>> hasItems(Iterable<T> items) {
        List<Matcher<? super Iterable<T>>> all = new LinkedList<Matcher<? super Iterable<T>>>();
        for (T element : items) {
            all.add(hasItem(element));
        }

        return allOf(all);
    }
1270688
def get_items_of_type(self, item_type):
        
        return (item for item in self.items if item.get_type() == item_type)
434843
public static <T> List<T> makeList(T... items) {
    List<T> s = new ArrayList<T>(items.length);
    for (int i = 0; i < items.length; i++) {
      s.add(items[i]);
    }
    return s;
  }
4063
def merge(self, items):
        
        if isinstance(items, BaseCollection):
            items = items.all()

        if not isinstance(items, list):
            raise ValueError('Unable to merge uncompatible types')

        self._items += items

        return self
117329
def iter_islast(iterable):
    
    it = iter(iterable)
    prev = next(it)
    for item in it:
        yield prev, False
        prev = item
    yield prev, True
1352589
def compare(self, other, base=None):
        
        if self.__class__ != other.__class__:
            return False, ''

        names = self._field_names_

        def cmp_func(name, s, o):
            # special case for string types
            if isinstance(s, six.string_types) and isinstance(o, six.string_types):
                return s == o, name

            if s.__class__ != o.__class__:
                return False, name

            if isinstance(s, BaseObj):
                if not isinstance(s, weakref.ProxyTypes):
                    return s.compare(o, name)
            elif isinstance(s, list):
                for i, v in zip(range(len(s)), s):
                    same, n = cmp_func(jp_compose(str(i), name), v, o[i])
                    if not same:
                        return same, n
            elif isinstance(s, dict):
                # compare if any key diff
                diff = list(set(s.keys()) - set(o.keys()))
                if diff:
                    return False, jp_compose(str(diff[0]), name)
                diff = list(set(o.keys()) - set(s.keys()))
                if diff:
                    return False, jp_compose(str(diff[0]), name)

                for k, v in six.iteritems(s):
                    same, n = cmp_func(jp_compose(k, name), v, o[k])
                    if not same:
                        return same, n
            else:
                return s == o, name

            return True, name

        for n in names:
            same, n = cmp_func(jp_compose(n, base), getattr(self, n), getattr(other, n))
            if not same:
                return same, n

        return True, ''
1165691
def recursive_bases(self):
        """"""
        if self._recursive_bases is None:
            to_go = self.bases[:]
            all_bases = []
            while to_go:
                base = to_go.pop()
                if base not in all_bases:
                    all_bases.append(base)
                    to_go.extend(base.related_class.bases)
            self._recursive_bases = all_bases
        return self._recursive_bases
1365748
def counter(items):
    
    results = {}
    for item in items:
        results[item] = results.get(item, 0) + 1
    return results
718250
def _get_batch_representative(items, key):
    
    if isinstance(items, dict):
        return items, items
    else:
        vals = set([])
        out = []
        for data in items:
            if key in data:
                vals.add(data[key])
                out.append(data)
        if len(vals) != 1:
            raise ValueError("Incorrect values for %s: %s" % (key, list(vals)))
        return out[0], items