tiledbsoma.DenseNDArray¶
- class tiledbsoma.DenseNDArray(handle: _WrapperType_co | DataFrameWrapper | DenseNDArrayWrapper | SparseNDArrayWrapper, *, _dont_call_this_use_create_or_open_instead: str = 'unset')¶
DenseNDArrayis a dense, N-dimensional array, with offset (zero-based) integer indexing on each dimension.DenseNDArrayhas a user-defined schema, which includes:The element type, expressed as an Arrow type indicating the type of data contained within the array.
The shape of the array, i.e., the number of dimensions and the length of each dimension.
All dimensions must have a positive, non-zero length, and there must be 1 or more dimensions.
Where explicitly referenced in the API, the dimensions are named
soma_dim_N, where N is the dimension number (e.g.,soma_dim_0), and elements are namedsoma_data.Lifecycle
Maturing.
Examples
>>> import tiledbsoma >>> import pyarrow as pa >>> import numpy as np >>> with tiledbsoma.DenseNDArray.create( ... "./test_dense_ndarray", type=pa.int32(), shape=(2, 3, 4) ... ) as arr: ... data = pa.Tensor.from_numpy( ... np.random.default_rng().integers(0, 10, 24).reshape(2, 3, 4) ... ) ... arr.write((slice(None),), data) ... with tiledbsoma.open("./test_dense_ndarray") as arr: ... print(arr.schema) ... print("---") ... print(arr.read()) ... soma_dim_0: int64 soma_dim_1: int64 soma_dim_2: int64 soma_data: int32 --- <pyarrow.Tensor> type: int32 shape: (2, 3, 4) strides: (48, 16, 4)
- __init__(handle: _WrapperType_co | DataFrameWrapper | DenseNDArrayWrapper | SparseNDArrayWrapper, *, _dont_call_this_use_create_or_open_instead: str = 'unset')¶
Internal-only common initializer steps.
This function is internal; users should open TileDB SOMA objects using the
create()andopen()factory class methods.
Methods
__init__(handle, *[, ...])Internal-only common initializer steps.
close()Release any resources held while the object is open.
create(uri, *, type, shape[, ...])Creates a SOMA
NDArrayat the given URI.exists(uri[, context, tiledb_timestamp])Finds whether an object of this type exists at the given URI.
non_empty_domain()Retrieves the non-empty domain for each dimension, namely the smallest and largest indices in each dimension for which the array/dataframe has data occupied.
open(uri[, mode, tiledb_timestamp, context, ...])Opens this specific type of SOMA object.
read([coords, result_order, partitions, ...])Reads a user-defined dense slice of the array and return as an Arrow
Tensor.reopen(mode[, tiledb_timestamp])Return a new copy of the SOMAObject with the given mode at the current Unix timestamp.
verify_open_for_writing()Raises an error if the object is not open for writing.
write(coords, values, *[, platform_config])Writes a subarray, defined by
coordsandvalues.Attributes
closedTrue if the object has been closed.
contextA value storing implementation-specific configuration information.
is_sparseTrue if the array is sparse, False if it is dense.
metadataThe metadata of this SOMA object.
modeThe mode this object was opened in, either
rorw.ndimThe number of dimensions in this array.
schemaReturns data schema, in the form of an Arrow Schema.
shapeReturns capacity of each dimension, always a list of length
ndim.soma_typeA string describing the SOMA type of this object.
tiledb_timestampThe time that this object was opened in UTC.
tiledb_timestamp_msThe time this object was opened, as millis since the Unix epoch.
uriAccessor for the object's storage URI.