Checks to see if all of the lists are the same length, and throws
    an AssertionError otherwise.  Returns the zipped lists.
428181
def zipLists(*lists):
    
    length = len(lists[0])
    for i, list_ in enumerate(lists[1:]):
        if len(list_) != length:
            msg = "List at index {} has length {} != {}".format(
                i + 1, len(list_), length)
            raise AssertionError(msg)
    return zip(*lists)
937154
def check_zip(self, token):
        
        if self.zip is None:
            # print "last matched", self.last_matched
            if self.last_matched is not None:
                return False
                # print "zip check", len(token) == 5, re.match(r"\d{5}", token)
            if len(token) == 5 and re.match(r"\d{5}", token):
                self.zip = self._clean(token)

                return True
        return False
125839
def ensure_list_size(list_, size_):
    
    lendiff = (size_) - len(list_)
    if lendiff > 0:
        extension = [None for _ in range(lendiff)]
        list_.extend(extension)
901757
def block_lengths(self):
        
        if self._lengths_cache is None:
            try:
                # The first column will have the correct lengths. We have an
                # invariant that requires that all blocks be the same length in a
                # row of blocks.
                self._lengths_cache = np.array(
                    ray.get([obj.length().oid for obj in self._partitions_cache.T[0]])
                    if len(self._partitions_cache.T) > 0
                    else []
                )
            except RayTaskError as e:
                handle_ray_task_error(e)
        return self._lengths_cache
262805
def get_collection_sizes(obj, collections: Optional[Tuple]=None,
                         get_only_non_empty=False):
    
    from pympler import asizeof
    collections = collections or (list, dict, set, deque, abc.Sized)
    if not isinstance(collections, tuple):
        collections = tuple(collections)

    result = []
    for attr_name in dir(obj):
        attr = getattr(obj, attr_name)
        if isinstance(attr, collections) and (
                not get_only_non_empty or len(attr) > 0):
            result.append(
                (attr_name, len(attr), asizeof.asizeof(attr, detail=1)))
    return result
1272839
def match_arr_lengths(l):
    
    try:
        # length of first list. use as basis to check other list lengths against.
        inner_len = len(l[0])
        # check each nested list
        for i in l:
            # if the length doesn't match the first list, then don't proceed.
            if len(i) != inner_len:
                return False
    except IndexError:
        # couldn't get index 0. Wrong data type given or not nested lists
        print("Error: Array data is not formatted correctly.")
        return False
    except TypeError:
        # Non-iterable data type given.
        print("Error: Array data missing")
        return False
    # all array lengths are equal. made it through the whole list successfully
    return True
256768
def collect_compare_zips_into(left, right, added, removed, altered, same):
    

    for event, filename in compare_zips(left, right):
        if event == LEFT:
            group = removed
        elif event == RIGHT:
            group = added
        elif event == DIFF:
            group = altered
        elif event == SAME:
            group = same
        else:
            assert False

        if group is not None:
            group.append(filename)

    return added, removed, altered, same
36644
def zip_and_tuple(self, x):
        
        return tuple(self.space.zip_inputs(np.atleast_2d(x)).flatten())
1104590
def duplicates(inlist):
    
    dups = []
    for i in range(len(inlist)):
        if inlist[i] in inlist[i+1:]:
            dups.append(inlist[i])
    return dups
1002320
def debug_consec_list(list_):
    
    if not issorted(list_):
        print('warning list is not sorted. indices will not match')
    sortedlist = sorted(list_)
    start = sortedlist[0]
    last = start - 1
    missing_vals = []
    missing_indices = []
    duplicate_items = []
    for count, item in enumerate(sortedlist):
        diff = item - last
        if diff > 1:
            missing_indices.append(count)
            for miss in range(last + 1, last + diff):
                missing_vals.append(miss)
        elif diff == 0:
            duplicate_items.append(item)
        elif diff == 1:
            # Expected case
            pass
        else:
            raise AssertionError('We sorted the list. diff can not be negative')
        last = item
    return missing_vals, missing_indices, duplicate_items
667756
def _check_split_list_validity(self):
        
        # FIXME: Currently very primitive, but needs to be fast
        if not (hasattr(self,"_splitListsSet") and (self._splitListsSet)):
            return False
        elif len(self) != self._splitListsLength:
            return False
        else:
            return True
1055645
def __isListOfLists(self, docs):
        
        return isinstance(docs, list) and \
               all(self.__isListOfTexts(ds) for ds in docs)
1101551
def _buffer_list_equal(a, b):
    
    if len(a) != len(b):
        return False
    if a == b:
        return True
    for ia, ib in zip(a, b):
        # Check byte equality, since bytes are what is actually synced
        # NOTE: Simple ia != ib does not always work as intended, as
        # e.g. memoryview(np.frombuffer(ia, dtype='float32')) !=
        # memoryview(np.frombuffer(b)), since the format info differs.
        if PY3:
            # compare without copying
            if memoryview(ia).cast('B') != memoryview(ib).cast('B'):
                return False
        else:
            # python 2 doesn't have memoryview.cast, so we may have to copy
            if isinstance(ia, memoryview) and ia.format != 'B':
                ia = ia.tobytes()
            if isinstance(ib, memoryview) and ib.format != 'B':
                ib = ib.tobytes()
            if ia != ib:
                return False
    return True
436236
def check_indexes_all_same(indexes, message="Indexes are not equal."):
    
    iterator = iter(indexes)
    first = next(iterator)
    for other in iterator:
        same = (first == other)
        if not same.all():
            bad_loc = np.flatnonzero(~same)[0]
            raise ValueError(
                "{}\nFirst difference is at index {}: "
                "{} != {}".format(
                    message, bad_loc, first[bad_loc], other[bad_loc]
                ),
            )
187909
def verify_equal_vector_lengths
      vector_lengths = @vectors.collect{|vector| vector.length}
      raise IndexError, "Unexpected behaviour: The vectors going into the STAPLE analysis have different lengths." unless vector_lengths.uniq.length == 1
    end
436520
def validate_list_of_identical_dicts(self, list_of_dicts):
        """"""
        hashes = []
        for _dict in list_of_dicts:
            hashes.append(hash(frozenset(_dict.items())))

        self.log.debug('Hashes: {}'.format(hashes))
        if len(set(hashes)) == 1:
            self.log.debug('Dicts within list are identical')
        else:
            return 'Dicts within list are not identical'

        return None
1235853
def equal_length(*args):
    
    for i, arg in enumerate(args):
        if not isinstance(arg, Sized):
            raise ExpectedTypeError(arg, ["Sized"])
        if i >= 1 and len(arg) != len(args[0]):
            raise DifferentLengthError(args, arg)