Generate bipartitions where one part is of length 1.
358953
def bipartition_of_one(seq):
    """"""
    seq = list(seq)
    for i, elt in enumerate(seq):
        yield ((elt,), tuple(seq[:i] + seq[(i + 1):]))
201338
function complexDivideRealPart(a,b){
                return (a[0]*b[0]+a[1]*b[1])/(b[0]*b[0]+b[1]*b[1]);
            }
1322281
def combine_elem(ind1, ind2):
    """"""
    def inner(seq):
        shift = 2**16
        if seq[ind1] < 0:
            seq[ind1] += shift
        if seq[ind2] < 0:
            seq[ind2] += shift
        return (seq[ind1] << 16) | seq[ind2]
    return inner
127271
def split_by_proportions(total, proportions, mininum_values):
    """"""
    assert(len(proportions) == len(mininum_values))
    assert(total >= sum(mininum_values))
    assert(min(proportions) > 0)
    num = len(proportions)
    sumProportions = float(sum(proportions))
    fractions = [p / sumProportions for p in proportions]
    result = [max(m, int(round(total * f)))
              for f, m in zip(fractions, mininum_values)]
    delta = sum(result) - total
    correct = -1 if delta > 0 else 1
    i = 0
    while delta != 0:
        if result[i] + correct >= mininum_values[i]:
            result[i] += correct
            delta += correct
        i = (i + 1) % num

    assert(sum(result) == total)
    return result
529605
def get_parts(self):
        
        parts = []
        start_b = 0
        end_byte = start_b + PartSize.DOWNLOAD_MINIMUM_PART_SIZE - 1
        for i in range(self.total):
            parts.append([start_b, end_byte])
            start_b = end_byte + 1
            end_byte = start_b + PartSize.DOWNLOAD_MINIMUM_PART_SIZE - 1
        return parts
412531
def _build_multipart(cls, data):
        
        boundary = b'--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
        sep_boundary = b'\n--' + boundary
        end_boundary = sep_boundary + b'--'
        end_items = end_boundary, b"\n",
        builder = functools.partial(
            cls._build_part,
            sep_boundary=sep_boundary,
        )
        part_groups = map(builder, data.items())
        parts = itertools.chain.from_iterable(part_groups)
        body_items = itertools.chain(parts, end_items)
        content_type = 'multipart/form-data; boundary=%s' % boundary.decode('ascii')
        return b''.join(body_items), content_type
100242
def semiconvergents(x):
    """"""

    (q, n), d = divmod(x.numerator, x.denominator), x.denominator
    yield Fraction(q)
    p0, q0, p1, q1 = 1, 0, q, 1
    while n:
        (q, n), d = divmod(d, n), n
        for _ in range(q):
            p0, q0 = p0+p1, q0+q1
            yield Fraction(p0, q0)
        p0, q0, p1, q1 = p1, q1, p0, q0
985288
def integer_partition(size: int, nparts: int) -> Iterator[List[List[int]]]:
    
    for part in algorithm_u(range(size), nparts):
        yield part
1121492
def _make_A_and_part_of_b_adjacent(self, ref_crds):
        
        rot = self._rotate_rows(ref_crds)
        A = 2*(rot - ref_crds)
        partial_b = (rot**2 - ref_crds**2).sum(1)
        return A, partial_b
567975
def chunks(l, n):
    """"""
    if n:
        for i in xrange(0, len(l), n):
            yield l[i:i + n]
173448
def slice_into_pieces(seq, n):
    """"""
    length = len(seq)
    if length % n == 0:
        size = length // n
    else:
        size = length // n + 1
    for it in slice_by_size(seq, size):
        yield it
236727
private void createPartitions(int numPartitions) {
		this.partitions.clear();
		
		ListMemorySegmentSource memSource = new ListMemorySegmentSource(this.availableMemory);
		
		for (int i = 0; i < numPartitions; i++) {
			this.partitions.add(new InMemoryPartition<T>(this.buildSideSerializer, i, memSource, this.segmentSize, pageSizeInBits));
		}
		this.compactionMemory = new InMemoryPartition<T>(this.buildSideSerializer, -1, memSource, this.segmentSize, pageSizeInBits);
	}
390153
def merge(data,skip=50,fraction=1.0):
    """"""

    w,s,d = data.chains.shape
    
    start = int((1.0 - fraction) * s)
    total = int((s - start) / skip)
        
    return data.chains[:,start::skip,:].reshape((w*total,d))
739197
def multipart(body, content_length=0, **header_params):
    """"""
    header_params.setdefault('CONTENT-LENGTH', content_length)
    if header_params and 'boundary' in header_params:
        if type(header_params['boundary']) is str:
            header_params['boundary'] = header_params['boundary'].encode()

    form = parse_multipart((body.stream if hasattr(body, 'stream') else body), header_params)
    for key, value in form.items():
        if type(value) is list and len(value) is 1:
            form[key] = value[0]
    return form
356667
def _create_partitions(self, instance, partitions):
        """"""
        for partition in partitions:
            RelationPartition.objects.create(
                relation=instance,
                entity=partition['entity'],
                label=partition.get('label', None),
                position=partition.get('position', None),
            )
779705
def split_size(size):
    ''''''
    rem = size % CHUNK_SIZE
    if rem == 0:
        cnt = size // CHUNK_SIZE
    else:
        cnt = size // CHUNK_SIZE + 1

    chunks = []
    for i in range(cnt):
        pos = i * CHUNK_SIZE
        if i == cnt - 1:
            disp = size - pos
        else:
            disp = CHUNK_SIZE
        chunks.append((pos, disp))
    return chunks
60243
def sia_bipartitions(nodes, node_labels=None):
    
    if config.CUT_ONE_APPROXIMATION:
        bipartitions = directed_bipartition_of_one(nodes)
    else:
        # Don't consider trivial partitions where one part is empty
        bipartitions = directed_bipartition(nodes, nontrivial=True)

    return [Cut(bipartition[0], bipartition[1], node_labels)
            for bipartition in bipartitions]