Skip to content

Commit

Permalink
Merge pull request #2891 from tdadela/filter-nonpositive-weight-in-th…
Browse files Browse the repository at this point in the history
…e-user-generator

Fix _kl_generator by filtering nonpositive weights
  • Loading branch information
cyberw authored Sep 6, 2024
2 parents f42d488 + 4e8f1c1 commit 7c85b79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion locust/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _kl_generator(users: Iterable[tuple[T, float]]) -> Generator[T | None]:
For example, given users A, B with weights 5 and 1 respectively,
this algorithm will yield AAABAAAAABAA.
"""
heap = [(x * log2(x / (x + 1.0)), x + 1.0, x, name) for name, x in users]
heap = [(x * log2(x / (x + 1.0)), x + 1.0, x, name) for name, x in users if x > 0]
if not heap:
while True:
yield None
Expand Down

0 comments on commit 7c85b79

Please sign in to comment.