tiled.client.container.Container.write_sparse

Container.write_sparse(coords, data, shape, *, key=None, metadata=None, dims=None, specs=None)[source]

EXPERIMENTAL: Write a sparse array.

Parameters:
coordsarray-like
dataarray-like
shapetuple
keystr, optional

Key (name) for this new node. If None, the server will provide a unique key.

metadatadict, optional

User metadata. May be nested. Must contain only basic types (e.g. numbers, strings, lists, dicts) that are JSON-serializable.

dimsList[str], optional

A label for each dimension of the array.

specsList[Spec], optional

List of names that are used to label that the data and/or metadata conform to some named standard specification.

Examples

Write a sparse.COO array.

>>> import sparse
>>> coo = sparse.COO(coords=[[2, 5]], data=[1.3, 7.5], shape=(10,))
>>> c.write_sparse(coords=coo.coords, data=coo.data, shape=coo.shape)

This only supports a single chunk. For chunked upload, use lower-level methods.

# Define the overall shape and the dimensions of each chunk. >>> from tiled.structures.sparse import COOStructure >>> structure = COOStructure(shape=(10,), chunks=((5, 5),)) >>> data_source = DataSource(structure=structure, structure_family=StructureFamily.sparse) >>> x = c.new(“sparse”, [data_source]) # Upload the data in each chunk. # Coords are given with in the reference frame of each chunk. >>> x.write_block(coords=[[2, 4]], data=[3.1, 2.8], block=(0,)) >>> x.write_block(coords=[[0, 1]], data=[6.7, 1.2], block=(1,))