split#

The inverse of Merge: partition a source-tagged stream back into one stream per source. split(*Merge()(a_v, b_v, index=[a_k, b_k])) reconstructs the original streams.

split(values, sources, index=None, n=None)[source]#

Partition a merged tagged stream back into per-source streams.

The inverse of merge. values may be a raw value array or a (values, index) tuple (which carries its own index); sources is always passed separately. Returns a list of (values, index) pairs. Positional (index=None) uses None for the per-source index. n sets how many output streams to produce (default: max(sources)+1); pass it explicitly to include sources that emitted nothing.

Example#

Merge two streams, then split them apart again and read back the first source.

import numpy as np
from screamer import Merge, split

a_v = np.array([1.0, 3.0])
a_k = np.array([1, 3])
b_v = np.array([2.0, 4.0])
b_k = np.array([2, 4])

merged_v, merged_s, merged_k = Merge()(a_v, b_v, index=[a_k, b_k])
streams = split(merged_v, merged_s, index=merged_k)
print(streams[0][0])   # values of source 0
[1. 3.]