Skip to content

Commit bb667d8

Browse files
committed
Linting
1 parent 3430da0 commit bb667d8

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

examples/global_order_writes.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#
3333

3434
import numpy as np
35+
3536
import tiledb
3637

3738
# Name of the arrays to create
@@ -60,23 +61,23 @@ def create_dense_array():
6061
def write_sparse_global_order():
6162
"""Write to sparse array in global order with multiple submits."""
6263
print("Writing sparse array in global order with multiple submits...")
63-
64+
6465
with tiledb.open(sparse_array_name, "w") as A:
6566
# Create a query with global order layout
6667
q = tiledb.Query(A, order="G")
67-
68+
6869
# First batch of data
6970
coords_batch1 = np.array([1, 5, 10, 20, 50], dtype=np.int32)
7071
data_batch1 = np.array([100, 200, 300, 400, 500], dtype=np.int64)
7172
q.set_data({"d1": coords_batch1, "a1": data_batch1})
7273
q.submit()
73-
74+
7475
# Second batch of data (coordinates must be in global order relative to first batch)
7576
coords_batch2 = np.array([100, 200, 500], dtype=np.int32)
7677
data_batch2 = np.array([600, 700, 800], dtype=np.int64)
7778
q.set_data({"d1": coords_batch2, "a1": data_batch2})
7879
q.submit()
79-
80+
8081
# Finalize to complete the write
8182
q.finalize()
8283

@@ -89,29 +90,29 @@ def write_sparse_global_order():
8990
def write_dense_global_order():
9091
"""Write to dense array in global order with multiple submits."""
9192
print("\nWriting dense array in global order with multiple submits...")
92-
93+
9394
with tiledb.open(dense_array_name, "w") as A:
9495
# Create a query with global order layout
9596
q = tiledb.Query(A, order="G")
96-
97+
9798
# Set the subarray to cover the full range we're writing
9899
start_coord = 1
99100
end_coord = 100
100101
q.set_subarray_ranges([(start_coord, end_coord)])
101-
102+
102103
# First batch of data (cells 1-50)
103104
data_batch1 = np.arange(1, 51, dtype=np.int64)
104105
q.set_data({"a1": data_batch1})
105106
q.submit()
106-
107+
107108
# Second batch of data (cells 51-100)
108109
data_batch2 = np.arange(51, 101, dtype=np.int64)
109110
q.set_data({"a1": data_batch2})
110111
q.submit()
111-
112+
112113
# Finalize to complete the write
113114
q.finalize()
114-
115+
115116
# Verify only one fragment was created
116117
fragments = tiledb.array_fragments(dense_array_name)
117118
print(f"Number of fragments created: {len(fragments)}")
@@ -121,13 +122,13 @@ def write_dense_global_order():
121122
def read_and_verify():
122123
"""Read back the data to verify it was written correctly."""
123124
print("\nReading and verifying data...")
124-
125+
125126
# Read sparse array
126127
with tiledb.open(sparse_array_name, "r") as A:
127128
result = A[:]
128129
print(f"Sparse array has {len(result['a1'])} cells")
129130
print(f"First 5 values: {result['a1'][:5]}")
130-
131+
131132
# Read dense array
132133
with tiledb.open(dense_array_name, "r") as A:
133134
result = A[1:20] # Read cells 1-19
@@ -138,20 +139,20 @@ def read_and_verify():
138139
print("=" * 60)
139140
print("TileDB Global Order Writes Example")
140141
print("=" * 60)
141-
142+
142143
# Check if arrays exist, create if not
143144
if tiledb.object_type(sparse_array_name) != "array":
144145
create_sparse_array()
145146
if tiledb.object_type(dense_array_name) != "array":
146147
create_dense_array()
147-
148+
148149
# Write data
149150
write_sparse_global_order()
150151
write_dense_global_order()
151-
152+
152153
# Read and verify
153154
read_and_verify()
154-
155+
155156
print("\n" + "=" * 60)
156157
print("Example completed successfully!")
157158
print("=" * 60)

0 commit comments

Comments
 (0)