Hey, is there any way to delete coordinates from a sparse array?
I noticed there is a “delete” mode on the docs - is that for the entire array or can I specify a sub-array?
Asking because I get junk values when I run:
with tiledb.open(uri,'r') as f:
f.df[:]
Hi @mdylan2,
Deletes work on dimension or attribute values that match a query condition. Here’s an example:
import tiledb, numpy as np
import tempfile
from numpy.testing import assert_array_equal
path = tempfile.mkdtemp("example_sparse_coord_delete")
print(path)
dom = tiledb.Domain(tiledb.Dim(name="x", domain=(1, 10), tile=1, dtype=np.uint32))
attrs = [tiledb.Attr("ints", dtype=np.uint32)]
schema = tiledb.ArraySchema(domain=dom, attrs=attrs, sparse=True)
tiledb.Array.create(path, schema)
data = np.random.randint(1, 10, 10)
qc = "x < 5"
with tiledb.open(path, "w") as A:
A[np.arange(1, 11)] = data
with tiledb.open(path, "d") as A:
A.query(cond=qc).submit()
with tiledb.open(path, "r") as A:
print(A[:])
You could similarly use "ints < 5"
, or other conditions on the attribute value instead.
Hope this helps,
Isaiah