def _evaluate(self, ctx, deps): array = deps['array'] src_slices = deps['src_slices'] data = deps['data'] dst_slices = deps['dst_slices'] sregion = extent.from_slice(src_slices, array.shape) if isinstance(data, np.ndarray) or sp.issparse(data): if sregion.shape == data.shape: array.update(sregion, data) else: array.update(sregion, data[dst_slices]) elif isinstance(data, distarray.DistArray): dst_slice = Slice(data, dst_slices) Assert.eq(sregion.shape, dst_slice.shape) array.foreach_tile(mapper_fn=_write_mapper, kw={ 'source': array, 'sregion': sregion, 'dst_slice': dst_slice }) else: raise TypeError return array
def _evaluate(self, ctx, deps): array = deps['array'] src_slices = deps['src_slices'] data = deps['data'] dst_slices = deps['dst_slices'] sregion = extent.from_slice(src_slices, array.shape) if isinstance(data, np.ndarray) or sp.issparse(data): if sregion.shape == data.shape: array.update(sregion, data) else: array.update(sregion, data[dst_slices]) elif isinstance(data, distarray.DistArray): dst_slice = Slice(data, dst_slices) Assert.eq(sregion.shape, dst_slice.shape) array.foreach_tile(mapper_fn = _write_mapper, kw = {'source':array, 'sregion':sregion, 'dst_slice':dst_slice}) else: raise TypeError return array
def test_from_slice(self): print extent.from_slice((slice(None), slice(None), 0), [100, 100, 100])