Skip to content

Commit d77cae5

Browse files
committed
style: apply black formatting
1 parent 6e064a9 commit d77cae5

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

src_py/database.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,29 @@ def _scan_node_table(
259259

260260
if prop_type == Type.INT64.value:
261261
result = np.empty(len(indices) * dim, dtype=np.int64)
262-
self._database.scan_node_table_as_int64(table_name, prop_name, indices_cast, result, num_threads)
262+
self._database.scan_node_table_as_int64(
263+
table_name, prop_name, indices_cast, result, num_threads
264+
)
263265
elif prop_type == Type.INT32.value:
264266
result = np.empty(len(indices) * dim, dtype=np.int32)
265-
self._database.scan_node_table_as_int32(table_name, prop_name, indices_cast, result, num_threads)
267+
self._database.scan_node_table_as_int32(
268+
table_name, prop_name, indices_cast, result, num_threads
269+
)
266270
elif prop_type == Type.INT16.value:
267271
result = np.empty(len(indices) * dim, dtype=np.int16)
268-
self._database.scan_node_table_as_int16(table_name, prop_name, indices_cast, result, num_threads)
272+
self._database.scan_node_table_as_int16(
273+
table_name, prop_name, indices_cast, result, num_threads
274+
)
269275
elif prop_type == Type.DOUBLE.value:
270276
result = np.empty(len(indices) * dim, dtype=np.float64)
271-
self._database.scan_node_table_as_double(table_name, prop_name, indices_cast, result, num_threads)
277+
self._database.scan_node_table_as_double(
278+
table_name, prop_name, indices_cast, result, num_threads
279+
)
272280
elif prop_type == Type.FLOAT.value:
273281
result = np.empty(len(indices) * dim, dtype=np.float32)
274-
self._database.scan_node_table_as_float(table_name, prop_name, indices_cast, result, num_threads)
282+
self._database.scan_node_table_as_float(
283+
table_name, prop_name, indices_cast, result, num_threads
284+
)
275285

276286
if result is not None:
277287
return result

test/test_mvcc_bank.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ def build_edges(n: int, prob: float, rng: random.Random) -> list[tuple[int, int]
7272

7373
def setup_db(db: lb.Database, n: int, edges: list[tuple[int, int]]) -> None:
7474
with lb.Connection(db) as conn:
75-
conn.execute("CREATE NODE TABLE Account (id INT64, balance INT64, PRIMARY KEY (id))")
75+
conn.execute(
76+
"CREATE NODE TABLE Account (id INT64, balance INT64, PRIMARY KEY (id))"
77+
)
7678
conn.execute("CREATE REL TABLE CanTransfer (FROM Account TO Account)")
7779
for i in range(n):
7880
conn.execute(f"CREATE (:Account {{id: {i}, balance: {INITIAL_BALANCE}}})")
7981
for src, dst in edges:
80-
conn.execute(f"MATCH (a:Account {{id: {src}}}), (b:Account {{id: {dst}}}) CREATE (a)-[:CanTransfer]->(b)")
82+
conn.execute(
83+
f"MATCH (a:Account {{id: {src}}}), (b:Account {{id: {dst}}}) CREATE (a)-[:CanTransfer]->(b)"
84+
)
8185

8286

8387
# ---------------------------------------------------------------------------
@@ -125,14 +129,20 @@ def write_worker(
125129
for attempt in range(RETRY_LIMIT):
126130
try:
127131
conn.execute("BEGIN TRANSACTION")
128-
row = conn.execute(f"MATCH (a:Account {{id: {src}}}) RETURN a.balance").get_next()
132+
row = conn.execute(
133+
f"MATCH (a:Account {{id: {src}}}) RETURN a.balance"
134+
).get_next()
129135
balance = row[0]
130136
if balance < amount:
131137
conn.execute("ROLLBACK")
132138
stats.inc("writes_skipped")
133139
break
134-
conn.execute(f"MATCH (a:Account {{id: {src}}}) SET a.balance = a.balance - {amount}")
135-
conn.execute(f"MATCH (b:Account {{id: {dst}}}) SET b.balance = b.balance + {amount}")
140+
conn.execute(
141+
f"MATCH (a:Account {{id: {src}}}) SET a.balance = a.balance - {amount}"
142+
)
143+
conn.execute(
144+
f"MATCH (b:Account {{id: {dst}}}) SET b.balance = b.balance + {amount}"
145+
)
136146
conn.execute("COMMIT")
137147
stats.inc("writes_committed")
138148
break
@@ -173,7 +183,9 @@ def read_worker(
173183
)
174184

175185
# 2: no negative balances
176-
neg = conn.execute("MATCH (a:Account) WHERE a.balance < 0 RETURN count(a)").get_next()[0]
186+
neg = conn.execute(
187+
"MATCH (a:Account) WHERE a.balance < 0 RETURN count(a)"
188+
).get_next()[0]
177189
if neg > 0:
178190
stats.anomaly(
179191
"negative_balance",
@@ -196,8 +208,12 @@ def read_worker(
196208
)
197209

198210
# 4: phantom read — aggregate must be stable
199-
agg1 = conn.execute("MATCH (a:Account) RETURN count(a), sum(a.balance)").get_next()
200-
agg2 = conn.execute("MATCH (a:Account) RETURN count(a), sum(a.balance)").get_next()
211+
agg1 = conn.execute(
212+
"MATCH (a:Account) RETURN count(a), sum(a.balance)"
213+
).get_next()
214+
agg2 = conn.execute(
215+
"MATCH (a:Account) RETURN count(a), sum(a.balance)"
216+
).get_next()
201217
if agg1 != agg2:
202218
stats.anomaly(
203219
"phantom_read",

0 commit comments

Comments
 (0)