Skip to content

Commit

Permalink
flake8 lint
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Yurick <[email protected]>
  • Loading branch information
sarahyurick committed Jan 16, 2025
1 parent bf8f9dc commit b8e2165
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crossfit/data/sparse/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ def to_pytrec(self, is_run=False):

qrel = {}
for i in range(self.indices.shape[0]):
query_id = f"q{i+1}"
query_id = f"q{i + 1}"
qrel[query_id] = {}

row = sparse_matrix[i]
for j, score in zip(row.indices, row.data):
doc_id = f"d{j+1}"
doc_id = f"d{j + 1}"
qrel[query_id][doc_id] = int(score) if is_run else float(score)

return qrel
Expand Down
6 changes: 3 additions & 3 deletions examples/dask_aggregate_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
t0 = time.time()
result = aggregate(ddf, agg, to_frame=True)
tf = time.time()
print(f"\nWall Time: {tf-t0} seconds\n")
print(f"\nWall Time: {tf - t0} seconds\n")

# View result
print(f"Result:\n{result}\n")
Expand All @@ -76,12 +76,12 @@
t0 = time.time()
std = ddf.groupby(groupby).std().compute()
tf = time.time()
print(f"\nddf.groupby().std() takes {tf-t0} seconds, and returns:\n")
print(f"\nddf.groupby().std() takes {tf - t0} seconds, and returns:\n")
print(f"\n{std}\n")
else:
# Compare to ddf.std()
t0 = time.time()
std = ddf.std().compute()
tf = time.time()
print(f"\nddf.std() takes {tf-t0} seconds, and returns:\n")
print(f"\nddf.std() takes {tf - t0} seconds, and returns:\n")
print(f"\n{std}\n")
10 changes: 5 additions & 5 deletions tests/pytrec_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def create_qrel(relevance_scores, ids=None):

qrel = {}
for i, query_scores in enumerate(relevance_scores):
query_id = ids[i] if ids is not None else f"q{i+1}"
query_id = ids[i] if ids is not None else f"q{i + 1}"
qrel[query_id] = {}
for j, score in enumerate(query_scores):
_score = int(score.item())

if _score > 0:
doc_id = f"d{j+1}"
doc_id = f"d{j + 1}"
qrel[query_id][doc_id] = int(score.item())

return qrel
Expand All @@ -41,10 +41,10 @@ def create_run(predicted_scores, ids=None):

run = {}
for i, query_scores in enumerate(predicted_scores):
query_id = ids[i] if ids is not None else f"q{i+1}"
query_id = ids[i] if ids is not None else f"q{i + 1}"
run[query_id] = {}
for j, score in enumerate(query_scores):
doc_id = f"d{j+1}"
doc_id = f"d{j + 1}"
run[query_id][doc_id] = float(score.item())

return run
Expand All @@ -60,6 +60,6 @@ def create_results(metric_arrays):
for k, v in metric_arrays.items():
q_out[k] = float(v[i])

outputs[f"q{i+1}"] = q_out
outputs[f"q{i + 1}"] = q_out

return outputs

0 comments on commit b8e2165

Please sign in to comment.