Parallel Dask Array A parallel nd-array comprised of many numpy arrays arranged in a grid. This constructor is for advanced uses only. For normal use see the :func:`dask.array.from_array` function. Parameters ---------- dask : dict Task dependency graph name :
| 1298 | |
| 1299 | |
| 1300 | class Array(DaskMethodsMixin): |
| 1301 | """Parallel Dask Array |
| 1302 | |
| 1303 | A parallel nd-array comprised of many numpy arrays arranged in a grid. |
| 1304 | |
| 1305 | This constructor is for advanced uses only. For normal use see the |
| 1306 | :func:`dask.array.from_array` function. |
| 1307 | |
| 1308 | Parameters |
| 1309 | ---------- |
| 1310 | dask : dict |
| 1311 | Task dependency graph |
| 1312 | name : string |
| 1313 | Name of array in dask |
| 1314 | chunks: iterable of tuples |
| 1315 | block sizes along each dimension |
| 1316 | dtype : str or dtype |
| 1317 | Typecode or data-type for the new Dask Array |
| 1318 | meta : empty ndarray |
| 1319 | empty ndarray created with same NumPy backend, ndim and dtype as the |
| 1320 | Dask Array being created (overrides dtype) |
| 1321 | shape : tuple of ints |
| 1322 | Shape of the entire array |
| 1323 | |
| 1324 | See Also |
| 1325 | -------- |
| 1326 | dask.array.from_array |
| 1327 | """ |
| 1328 | |
| 1329 | __slots__ = "dask", "__name", "_cached_keys", "__chunks", "_meta", "__dict__" |
| 1330 | |
| 1331 | def __new__(cls, dask, name, chunks, dtype=None, meta=None, shape=None): |
| 1332 | self = super().__new__(cls) |
| 1333 | assert isinstance(dask, Mapping) |
| 1334 | if not isinstance(dask, HighLevelGraph): |
| 1335 | dask = HighLevelGraph.from_collections(name, dask, dependencies=()) |
| 1336 | self.dask = dask |
| 1337 | self._name = str(name) |
| 1338 | meta = meta_from_array(meta, dtype=dtype) |
| 1339 | |
| 1340 | if ( |
| 1341 | isinstance(chunks, str) |
| 1342 | or isinstance(chunks, tuple) |
| 1343 | and chunks |
| 1344 | and any(isinstance(c, str) for c in chunks) |
| 1345 | ): |
| 1346 | dt = meta.dtype |
| 1347 | else: |
| 1348 | dt = None |
| 1349 | self._chunks = normalize_chunks(chunks, shape, dtype=dt) |
| 1350 | if self.chunks is None: |
| 1351 | raise ValueError(CHUNKS_NONE_ERROR_MESSAGE) |
| 1352 | self._meta = meta_from_array(meta, ndim=self.ndim, dtype=dtype) |
| 1353 | |
| 1354 | for plugin in config.get("array_plugins", ()): |
| 1355 | result = plugin(self) |
| 1356 | if result is not None: |
| 1357 | self = result |
searching dependent graphs…