MCPcopy Create free account
hub / github.com/dask/dask / from_tiledb

Function from_tiledb

dask/array/tiledb_io.py:11–71  ·  view source on GitHub ↗

Load array from the TileDB storage format See https://docs.tiledb.io for more information about TileDB. Parameters ---------- uri: TileDB array or str Location to save the data attribute: str or None Attribute selection (single-attribute view on multi-attribute

(uri, attribute=None, chunks=None, storage_options=None, **kwargs)

Source from the content-addressed store, hash-verified

9
10
11def from_tiledb(uri, attribute=None, chunks=None, storage_options=None, **kwargs):
12 """Load array from the TileDB storage format
13
14 See https://docs.tiledb.io for more information about TileDB.
15
16 Parameters
17 ----------
18 uri: TileDB array or str
19 Location to save the data
20 attribute: str or None
21 Attribute selection (single-attribute view on multi-attribute array)
22
23
24 Returns
25 -------
26
27 A Dask Array
28
29 Examples
30 --------
31
32 >>> import tempfile, tiledb
33 >>> import dask.array as da, numpy as np
34 >>> uri = tempfile.NamedTemporaryFile().name
35 >>> _ = tiledb.from_numpy(uri, np.arange(0,9).reshape(3,3)) # create a tiledb array
36 >>> tdb_ar = da.from_tiledb(uri) # read back the array
37 >>> tdb_ar.shape
38 (3, 3)
39 >>> tdb_ar.mean().compute()
40 4.0
41 """
42 import tiledb
43
44 tiledb_config = storage_options or dict()
45 key = tiledb_config.pop("key", None)
46
47 if isinstance(uri, tiledb.Array):
48 tdb = uri
49 else:
50 tdb = tiledb.open(uri, attr=attribute, config=tiledb_config, key=key)
51
52 if tdb.schema.sparse:
53 raise ValueError("Sparse TileDB arrays are not supported")
54
55 if not attribute:
56 if tdb.schema.nattr > 1:
57 raise TypeError(
58 "keyword 'attribute' must be provided"
59 "when loading a multi-attribute TileDB array"
60 )
61 else:
62 attribute = tdb.schema.attr(0).name
63
64 if tdb.iswritable:
65 raise ValueError("TileDB array must be open for reading")
66
67 chunks = chunks or _tiledb_to_chunks(tdb)
68

Callers

nothing calls this directly

Calls 2

_tiledb_to_chunksFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected