tiled.client.array.DaskArrayClient.patch
- DaskArrayClient.patch(array: ndarray[Any, dtype[_ScalarType_co]], offset: int | tuple[int, ...], extend=False)
Write data into a slice of an array, maybe extending the shape.
- Parameters:
- arrayarray-like
The data to write
- offsettuple[int, …]
Where to place this data in the array
- extendbool
Extend the array shape to fit the new slice, if necessary
Examples
Create a (3, 2, 2) array of ones.
>>> ac = c.write_array(numpy.ones((3, 2, 2)), key='y') >>> ac <ArrayClient shape=(3, 2, 2) chunks=((3,), (2,), (2,)) dtype=float64>
Read it.
>>> ac.read() array([[[1., 1.], [1., 1.]],
- [[1., 1.],
[1., 1.]],
- [[1., 1.],
[1., 1.]]])
Extend the array by concatenating a (1, 2, 2) array of zeros.
>>> ac.patch(numpy.zeros((1, 2, 2)), offset=(3,), extend=True)
Read it.
>>> array([[[1., 1.], [1., 1.]],
- [[1., 1.],
[1., 1.]],
- [[1., 1.],
[1., 1.]],
- [[0., 0.],
[0., 0.]]])