join

function of dascore.lazy.array source

join(
    arrays: Sequence ,
    axis: int ,
    new_axis: bool = False,
)

Join arrays end to end along an axis, on the backend they are on.

Lazy arrays with nothing pending are a window of what is stored, and are joined by their recipes, reading nothing: the result is lazy. Any other arrays held on one library are joined there, by the library’s own concat, so they are never taken through NumPy. What cannot be joined either way – lazy arrays with operations pending, a mix of lazy and in-memory arrays or of libraries, or a new axis on lazy arrays – is read or converted only as the numpy_fallback setting allows.

Parameters

Parameter Description
arrays The arrays to join; they agree on every other axis.
axis The axis to join along.
new_axis Give each array a new axis of length one at the end first, and
join along it, as stacking does.

Examples

import numpy as np
from dascore.core.source import ArraySource
from dascore.lazy.array import LazyArray, join
from dascore.lazy.recipe import Recipe

full = (ArraySource.full((2, 3), x) for x in (1, 2))
parts = [LazyArray(Recipe.from_source(x)) for x in full]
joined = join(parts, axis=1)
assert isinstance(joined, LazyArray) and joined.shape == (2, 6)
assert np.array_equal(join([np.ones(2), np.zeros(2)], 0), [1, 1, 0, 0])