Use a predicate to partition true and false entries.

    Reference
    ---------
    Python itertools documentation.
512101
def partition(predicate, iterable):
    

    t1, t2 = tee(iterable)

    return filterfalse(predicate, t1), filter(predicate, t2)
1165467
def _build_full_partition(
        optional_parts, sequence_var_partition: Sequence[int], subjects: Sequence[Expression], operation: Operation
) -> List[Sequence[Expression]]:
    
    i = 0
    var_index = 0
    opt_index = 0
    result = []
    for operand in op_iter(operation):
        wrap_associative = False
        if isinstance(operand, Wildcard):
            count = operand.min_count if operand.optional is None else 0
            if not operand.fixed_size or isinstance(operation, AssociativeOperation):
                count += sequence_var_partition[var_index]
                var_index += 1
                wrap_associative = operand.fixed_size and operand.min_count
            elif operand.optional is not None:
                count = optional_parts[opt_index]
                opt_index += 1
        else:
            count = 1

        operand_expressions = list(op_iter(subjects))[i:i + count]
        i += count

        if wrap_associative and len(operand_expressions) > wrap_associative:
            fixed = wrap_associative - 1
            operand_expressions = tuple(operand_expressions[:fixed]) + (
                create_operation_expression(operation, operand_expressions[fixed:]),
            )

        result.append(operand_expressions)

    return result
996440
def _recv_predicate(self, predicate, timeout='default', raise_eof=True):
        

        if timeout == 'default':
            timeout = self._timeout

        self.timed_out = False

        start = time.time()
        try:
            while True:
                cut_at = predicate(self.buf)
                if cut_at > 0:
                    break
                if timeout is not None:
                    time_elapsed = time.time() - start
                    if time_elapsed > timeout:
                        raise socket.timeout
                    self._settimeout(timeout - time_elapsed)

                data = self._recv(4096)
                self._log_recv(data, False)
                self.buf += data

                if not data:
                    if raise_eof:
                        raise NetcatError("Connection dropped!")
                    cut_at = len(self.buf)
                    break

        except KeyboardInterrupt:
            self._print_header('\n======== Connection interrupted! ========')
            raise
        except socket.timeout:
            self.timed_out = True
            if self._raise_timeout:
                raise NetcatTimeout()
            return b''
        except socket.error as exc:
            raise NetcatError('Socket error: %r' % exc)

        self._settimeout(self._timeout)

        ret = self.buf[:cut_at]
        self.buf = self.buf[cut_at:]
        self._log_recv(ret, True)
        return ret
790624
def parse_partition(rule):
    '''
    
    '''
    parser = argparse.ArgumentParser()
    rules = shlex.split(rule)
    rules.pop(0)
    parser.add_argument('mntpoint')
    parser.add_argument('--size', dest='size', action='store')
    parser.add_argument('--grow', dest='grow', action='store_true')
    parser.add_argument('--maxsize', dest='maxsize', action='store')
    parser.add_argument('--noformat', dest='noformat', action='store_true')
    parser.add_argument('--onpart', '--usepart', dest='onpart', action='store')
    parser.add_argument('--ondisk', '--ondrive', dest='ondisk', action='store')
    parser.add_argument('--asprimary', dest='asprimary', action='store_true')
    parser.add_argument('--fsprofile', dest='fsprofile', action='store')
    parser.add_argument('--fstype', dest='fstype', action='store')
    parser.add_argument('--fsoptions', dest='fsoptions', action='store')
    parser.add_argument('--label', dest='label', action='store')
    parser.add_argument('--recommended', dest='recommended',
                        action='store_true')
    parser.add_argument('--onbiosdisk', dest='onbiosdisk', action='store')
    parser.add_argument('--encrypted', dest='encrypted', action='store_true')
    parser.add_argument('--passphrase', dest='passphrase', action='store')
    parser.add_argument('--escrowcert', dest='escrowcert', action='store')
    parser.add_argument('--backupphrase', dest='backupphrase', action='store')

    args = clean_args(vars(parser.parse_args(rules)))
    parser = None
    return args
474866
public static <T> Predicate<T> in(final Iterable<T> it) {
    return new Predicate<T>() {
      @Override
      public boolean apply(T obj) {
        for (T elem : it) {
          if (Objects.equal(elem, obj)) {
            return true;
          }
        }
        return false;
      }
    };
  }
324933
def partition(self):
        """"""

        if not self.partitions:
            return None

        if len(self.partitions) > 1:
            raise ValueError(
                "Can't use this method when there is more than one partition")

        return list(self.partitions.values())[0]
765455
def is_valid_continuous_partition_object(partition_object):
    
    if (partition_object is None) or ("weights" not in partition_object) or ("bins" not in partition_object):
        return False
    if("tail_weights" in partition_object):
        if (len(partition_object["tail_weights"])!=2):
            return False
        comb_weights=partition_object["tail_weights"]+partition_object["weights"]
    else:
        comb_weights=partition_object["weights"]
    # Expect one more bin edge than weight; all bin edges should be monotonically increasing; weights should sum to one
    if (len(partition_object['bins']) == (len(partition_object['weights']) + 1)) and \
            np.all(np.diff(partition_object['bins']) > 0) and \
            np.allclose(np.sum(comb_weights), 1):
        return True
    return False
2551
def partition_all(n, iterable):
    
    it = iter(iterable)
    while True:
        chunk = list(itertools.islice(it, n))
        if not chunk:
            break
        yield chunk
703730
def p_x_boolx(self,t):
    
    # todo: ply exposes precedence with %prec, use it.
    if len(t)==4: t[0] = bin_priority(t[2],t[1],t[3])
    elif len(t)==3: t[0] = un_priority(t[1],t[2])
    else: raise NotImplementedError('unk_len',len(t)) # pragma: no cover
1340288
def partition(molList, options):
    
    # set input variables
    status_field = options.status_field
    active_label = options.active_label
    decoy_label = options.decoy_label

    # initiate lists
    activeList = []
    decoyList = []

    # partition moList
    for mol in molList:
        if mol.GetProp(status_field) == active_label:
            activeList.append(mol)
        elif mol.GetProp(status_field) == decoy_label:
            decoyList.append(mol)

    # return partitions
    return activeList, decoyList
245319
def split_every(parts, iterable):
    
    return takewhile(bool, (list(islice(iterable, parts)) for _ in count()))
807147
def mapPartitions(self, f, preservesPartitioning=False):
        
        return (
            self
            .mapPartitionsWithIndex(lambda i, p: f(p), preservesPartitioning)
            .transform(lambda rdd:
                       rdd.setName('{}:{}'.format(rdd.prev.name(), f)))
        )
1144000
def partition(f, xs):
    
    t = type(xs)
    true = filter(f, xs)
    false = [x for x in xs if x not in true]
    return t(true), t(false)
1288727
def partition(pred, iterable):
    ''
    # partition(is_odd, range(10)) --> 0 2 4 6 8   and  1 3 5 7 9
    t1, t2 = itertools.tee(iterable)
    try:
        return itertools.ifilterfalse(pred, t1), itertools.ifilter(pred, t2)
    except:
        return itertools.filterfalse(pred, t1), filter(pred, t2)
427624
def as_partition(self, **kwargs):
        """"""

        return PartitionName(**dict(list(self.dict.items()) + list(kwargs.items())))
1030499
def filterBy(self, **kwargs):
        ''' '''
        criteria = ['seeds', 'size']
        for k, v in kwargs.iteritems():
            if k in criteria:
                self.results = filter(
                    lambda x: getattr(x, k) >= v, self.results)
        return self
1155854
def _remove_files(self, predicate):
        
        found = False
        for i in range(len(self.files) - 1, -1, -1):
            if predicate(self.files[i]):
                self.debug_print(" removing " + self.files[i])
                del self.files[i]
                found = True
        return found