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))array
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 kernel for the array’s backend in order, a chunk at a time when the whole would be large; see dascore.lazy.execute.
Examples
Functions
| Name | Description |
|---|---|
| cast_on_library | Return an array cast to a NumPy dtype, on the library it is on. |
| join | Join arrays end to end along an axis, on the backend they are on. |
Classes
| Name | Description |
|---|---|
| LazyArray | A recipe, and the operations pending on it. |