Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dtype="int32")
array_strs = np.array([[b"a", b"bb", b"e", b"ff"],
[b"ccc", b"dddd", b"ggg", b"hhhh"],
[b"i", b"jj", b"m", b"nn"],
[b"kkk", b"llll", b"ooo", b"pppp"]],
dtype="S4")
array_pairs = np.array([[(0.1, 0.2), (1.1, 1.2), (4.1, 4.2), (5.1, 5.2)],
[(1.1, 1.2), (3.1, 3.2), (6.1, 6.2), (7.1, 7.2)],
[(8.1, 8.2), (9.1, 9.2), (12.1, 12.2), (13.1, 13.2)],
[(10.1, 10.2), (11.1, 11.2), (14.1, 14.2), (15.1, 15.2)]],
dtype="float32,float32")
ctx = tiledb.Ctx()
dense_example = tiledb.DenseArray.load(ctx, "my_dense_array")
dense_example[:] = {"a1": array_ints,
"a2": array_strs,
"a3": array_pairs}
def main():
# Create TileDB context
ctx = tiledb.Ctx()
# Load the dense array schema
dense_example = tiledb.DenseArray.load(ctx, "my_dense_array")
# Retrieve and print the non-empty domain
nonempty = dense_example.nonempty_domain()
print("Non-empty domain:")
for i in range(dense_example.ndim):
print("{0!s}: {1!r}".format(dense_example.domain.dim(i).name, nonempty[i]))
# Read the entire array. `result` is a dict of numpy arrays
result = dense_example[:]
# Print the results
result_num = result["a1"].size
print("\nResult num: ", result_num)
print()
print("{:<5s}{:<10s}{:<10s}{:<10s}".format("a1", "a2", "a3[0]", "a3[1]"))
print("------------------------------")
def main():
# Create TileDB context
ctx = tiledb.Ctx()
# Load the dense array schema
dense_example = tiledb.DenseArray.load(ctx, "my_dense_array")
# Retrieve and print the non-empty domain
nonempty = dense_example.nonempty_domain()
print("Non-empty domain:")
for i in range(dense_example.ndim):
print("{0!s}: {1!r}".format(dense_example.domain.dim(i).name, nonempty[i]))
# Read an array slice. `result` is a dict of numpy arrays
result = dense_example[3:5, 3:5]
# Print the results
result_num = result["a1"].size
print("\nResult num: ", result_num)
print()
print("{:<5s}{:<10s}{:<10s}{:<10s}".format("a1", "a2", "a3[0]", "a3[1]"))
print("------------------------------")