array

module of dascore.lazy source

A lazy array: a recipe and the operations pending on it.

A LazyArray is what a patch holds when its data are not read yet. The Recipe says which stored samples fill which box of the array, and the Chain holds the operations run on it since, none of which has computed anything. Its shape, dtype and data_id are the last step’s, or the recipe’s when nothing is pending, so they are known without reading. load reads the recipe and runs each step’s NumPy kernel in order, in memory.

Examples

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

recipe = Recipe.from_source(ArraySource.full((4, 3), -2.0))
array = LazyArray(recipe)
assert array.shape == (4, 3) and len(array) == 4
assert array.data_id == recipe.data_id
assert np.array_equal(array.load(), np.full((4, 3), -2.0))

Classes

Name Description
LazyArray A recipe, and the operations pending on it.