I would like to update values of a particular attribute at a particular slice in a sparse array. I read on the tiledb docs that currently this is not supported; I have to write to all attributes when performing a write operation. So I created a dictionary where the keys are the attribute names, and the values are the numpy arrays of the slice I am writing to. For the attributes I don’t overwrite, these remain the same. For the one attribute I want to overwrite, it becomes an array of equal length to the existing slice, but with the new vales. I get the following error:
1.)
with tiledb.open(array_name,mode='r') as props:
# Get all the attribute names (because to update values of one attr we have to do so for all???)
attr = [props.schema.attr(n).name for n in range(props.schema.nattr)]
# Create a dictionary of the values at each attr at the desired slice:
attr_vals = {a:props[:,"str_idx_2_slice",:,:][a] for a in attr}
2.)
with tiledb.open(array_name,mode='w') as A:
# Change the values of the attribute named "complete" (at this slice) to all 1's:
attr_vals["complete"] = np.ones(attr_vals["complete"].shape, dtype=np.int8)
# Write the update at the slice
A[:,"str_idx_2_slice",:,:] = attr_vals
[Output]
ValueError: Could not convert object to NumPy datetime
Here’s the schema ("str_idx_2_slice"
is a named index in the TrialID
index) I have hidden the attributes I am not attempting to overwrite because they are irrelevant here:
ArraySchema(
domain=Domain(*[
Dim(name='timestamp', domain=(numpy.datetime64('1677-09-21T00:12:43.145224193'), numpy.datetime64('2262-04-11T23:47:16.854775797')), tile=numpy.timedelta64(10,'ns'), dtype='datetime64[ns]', filters=FilterList([ZstdFilter(level=-1), ])),
Dim(name='TrialID', domain=('', ''), tile=None, dtype='|S0', var=True, filters=FilterList([ZstdFilter(level=-1), ])),
Dim(name='TankID', domain=('', ''), tile=None, dtype='|S0', var=True, filters=FilterList([ZstdFilter(level=-1), ])),
Dim(name='fluidtype', domain=('', ''), tile=None, dtype='|S0', var=True, filters=FilterList([ZstdFilter(level=-1), ])),
]),
attrs=[
...
Attr(name='complete', dtype='int8', var=False, nullable=False, filters=FilterList([ZstdFilter(level=-1), ])),
],
cell_order='row-major',
tile_order='row-major',
capacity=10000,
sparse=True,
allows_duplicates=True,
)
Any help would be greatly appreciated