Skip to content

Commit 8b83ebb

Browse files
limqiyingfacebook-github-bot
authored andcommitted
fix python blank space lints (facebookresearch#4560)
Summary: Pull Request resolved: facebookresearch#4560 **What:** Fixed 73 Python \E302 linting errors by adding missing blank lines before function definitions. **Why:** Python PEP 8 style guide requires 2 blank lines before top-level function and class definitions. The codebase had functions with only 1 blank line preceding them, causing linting failures. **Changes:** Added one additional blank line before function definitions across 12 files in the faiss codebase to meet the "expected 2 blank lines, found 1" requirement. **Impact:** Brings Python code into compliance with standard formatting rules without affecting functionality. Reviewed By: trang-nm-nguyen Differential Revision: D81080938 fbshipit-source-id: dd5e02c52229ca77db38b465bdaadd9bfa83801a
1 parent fa55327 commit 8b83ebb

28 files changed

+52
-5
lines changed

benchs/bench_all_ivf/bench_all_ivf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def eval_setting(index, xq, gt, k, inter, min_time):
104104
# Training
105105
######################################################
106106

107+
107108
def run_train(args, ds, res):
108109
nq, d = ds.nq, ds.d
109110
nb, d = ds.nq, ds.d
@@ -235,6 +236,7 @@ def run_train(args, ds, res):
235236
# Populating index
236237
######################################################
237238

239+
238240
def run_add(args, ds, index, res):
239241

240242
print("adding")
@@ -564,4 +566,4 @@ def aa(*args, **kwargs):
564566

565567

566568
if __name__ == "__main__":
567-
main()
569+
main()

benchs/bench_all_ivf/cmp_with_scann.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def eval_recalls(name, I, gt, times):
2323
s += "time: %.4f s (± %.4f)" % (np.mean(times), np.std(times))
2424
print(s)
2525

26+
2627
def eval_inters(name, I, gt, times):
2728
k = I.shape[1]
2829
s = "%-40s inter" % name
@@ -168,6 +169,7 @@ def aa(*args, **kwargs):
168169
# SCANN
169170
###############################################################
170171

172+
171173
def scann_make_index(xb, distance_measure, scann_dir, reorder_k):
172174
import scann
173175

benchs/bench_all_ivf/datasets_oss.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
faiss_datasets.dataset_basedir = '/checkpoint/matthijs/simsearch/'
1919

20+
2021
def sanitize(x):
2122
return np.ascontiguousarray(x, dtype='float32')
2223

benchs/bench_all_ivf/parse_bench_all_ivf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def collect_results_for(db='deep1M', prefix="autotune."):
153153

154154
return allres, allstats
155155

156+
156157
def extract_pareto_optimal(allres, keys, recall_idx=0, times_idx=3):
157158
bigtab = []
158159
for i, k in enumerate(keys):
@@ -183,6 +184,7 @@ def extract_pareto_optimal(allres, keys, recall_idx=0, times_idx=3):
183184

184185
return selected_keys, ops
185186

187+
186188
def plot_subset(
187189
allres, allstats, selected_methods, recall_idx, times_idx=3,
188190
report=["overhead", "build time"]):

benchs/bench_for_interrupt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
parser = argparse.ArgumentParser()
1616

17+
1718
def aa(*args, **kwargs):
1819
group.add_argument(*args, **kwargs)
1920

benchs/bench_fw_codecs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
logging.basicConfig(level=logging.INFO)
1515

16+
1617
def factory_factory(d):
1718
return [
1819
("SQ4", None, 256 * (2 ** 10), None),
@@ -77,6 +78,7 @@ def factory_factory(d):
7778
if d % sub == 0
7879
]
7980

81+
8082
def run_local(rp):
8183
bio, d, tablename, distance_metric = rp
8284
if tablename == "contriever":
@@ -120,6 +122,7 @@ def run_local(rp):
120122
benchmark.set_io(bio)
121123
benchmark.benchmark(result_file="result.json", train=True, reconstruct=False, knn=False, range=False)
122124

125+
123126
def run(bio, d, tablename, distance_metric):
124127
bio.launch_jobs(run_local, [(bio, d, tablename, distance_metric)], local=True)
125128

benchs/bench_fw_ivf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def bigann(bio):
7171
benchmark.set_io(bio)
7272
benchmark.benchmark(f"result{scale}.json", local=False, train=True, reconstruct=False, knn=True, range=False)
7373

74+
7475
def ssnpp(bio):
7576
benchmark = Benchmark(
7677
num_threads=32,

benchs/bench_gpu_1bn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,13 @@ def usage():
123123
# we mem-map the biggest files to avoid having them in memory all at
124124
# once
125125

126+
126127
def mmap_fvecs(fname):
127128
x = np.memmap(fname, dtype='int32', mode='r')
128129
d = x[0]
129130
return x.view('float32').reshape(-1, d + 1)[:, 1:]
130131

132+
131133
def mmap_bvecs(fname):
132134
x = np.memmap(fname, dtype='uint8', mode='r')
133135
d = x[:4].view('int32')[0]
@@ -560,6 +562,7 @@ def compute_populated_index(preproc):
560562

561563
return gpu_index, indexall
562564

565+
563566
def compute_populated_index_2(preproc):
564567

565568
indexall = prepare_trained_index(preproc)

benchs/bench_pq_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
os.system("grep -m1 'model name' < /proc/cpuinfo")
1313

14+
1415
def format_tab(x):
1516
return "\n".join("\t".join("%g" % xi for xi in row) for row in x)
1617

1718

1819
def run_bench(d, dsub, nbit=8, metric=None):
19-
2020
M = d // dsub
2121
pq = faiss.ProductQuantizer(d, M, nbit)
2222
pq.train(faiss.randn((max(1000, pq.ksub * 50), d), 123))

benchs/distributed_ondisk/distributed_query_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
sindex.set_prefetch_nthread(0)
4444
sindex.set_omp_num_threads(64)
4545

46+
4647
def ivecs_read(fname):
4748
a = np.fromfile(fname, dtype='int32')
4849
d = a[0]
4950
return a.reshape(-1, d + 1)[:, 1:].copy()
5051

52+
5153
def fvecs_read(fname):
5254
return ivecs_read(fname).view('float32')
5355

0 commit comments

Comments
 (0)