Skip to content

Commit

Permalink
fix string hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
rectalogic committed Oct 2, 2024
1 parent 6df8c3b commit 5ef9124
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,14 @@ def prepare_table():
}


# hash(s) is not idempotent across interpreter runs
def djb2(s: str) -> int:
h = 5381
for c in s.encode():
h = ((h << 5) + h) + c
return h


@pytest.mark.parametrize(
"llm_args,validator",
[
Expand All @@ -629,7 +637,7 @@ def prepare_table():
# actions runners (due to disk space issues on the runners)
marks=[
pytest.mark.llm,
marks[hash(key) % len(marks)],
marks[djb2(key) % len(marks)],
],
)
for key, values in testdata.items()
Expand Down

0 comments on commit 5ef9124

Please sign in to comment.