Storing waveform segment as var attr in sparse array

Hello, TileDB users and team. I hope someone can help me solve a problem I am having when trying write to a sparse array that has a single var attr (np.float64). It’s likely I have overlooked something simple – so I appreciate an outside look.

I am trying to write short segments of waveform of size (480,) – also type np.float64. Each segment is timestamped at 2s interval.

I am running into Type Error “Failed to convert buffer for attribute: ‘value’” when attempting to write.

Running in Conda env with:
Python 3.8.6
tiledb 2.1.6
tiledb-py 0.7.6 — from conda-forge
numpy 1.19.5
pandas 1.2.1

import numpy as np
import pandas as pd
import tiledb

dim_start = pd.to_datetime("2020-01-01").to_numpy()
dim_end = pd.to_datetime("2020-01-02").to_numpy()

schema = tiledb.ArraySchema(
    domain=tiledb.Domain(
        tiledb.Dim(
            name="idx", domain=(dim_start, dim_end), tile=1_000_000, dtype="datetime64[ns]"
        )
    ),
    attrs=[tiledb.Attr(name="value", var=True, dtype=np.float64)],
    sparse=True,
    capacity=10_000,
)

schema.check()
tiledb.SparseArray.create("sparse_test", schema)

# CREATE AND WRITE SOME DATA
# timestamps (idx)
times = np.arange(dim_start, dim_end, np.timedelta64(2, "s"))

# fake signal
random_signal = np.random.random_sample((times.shape[0], 480))
signal_container = np.empty((times.shape[0],), dtype="O")

for idx, value in enumerate(random_signal):
    signal_container[idx] = value.astype(np.float64)

with tiledb.SparseArray("sparse_test", "w") as A:
    A[times] = {"value": signal_container}

Hi @alexhamiltonRN,

This was a bug, and is fixed in TileDB-Py 0.7.7 as well as the latest version 0.8.2. @gsakkis and I tested your code successfully on 0.7.7 and 0.8.2, but please let us know if updating does not resolve.

Best,
Isaiah

Works beautifully! Thanks @ihnorton