Skip to content

Commit

Permalink
don't really need deque
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Dec 19, 2023
1 parent 8fae6c4 commit 3ae13e2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions dedupe/branch_and_bound.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import collections
import functools
from typing import Any, Iterable, Mapping, Sequence, Tuple

Expand Down Expand Up @@ -56,10 +55,10 @@ def _covered(partial: Partial) -> int:
cheapest: Partial = ()

Check warning on line 55 in dedupe/branch_and_bound.py

View check run for this annotation

Codecov / codecov/patch

dedupe/branch_and_bound.py#L54-L55

Added lines #L54 - L55 were not covered by tests

start: tuple[Cover, Partial] = (original_cover, ())
to_explore = collections.deque((start,))
to_explore = [start]

Check warning on line 58 in dedupe/branch_and_bound.py

View check run for this annotation

Codecov / codecov/patch

dedupe/branch_and_bound.py#L57-L58

Added lines #L57 - L58 were not covered by tests

while to_explore and calls:
candidates, partial = to_explore.popleft()
candidates, partial = to_explore.pop()

Check warning on line 61 in dedupe/branch_and_bound.py

View check run for this annotation

Codecov / codecov/patch

dedupe/branch_and_bound.py#L60-L61

Added lines #L60 - L61 were not covered by tests

covered = _covered(partial)
score = _score(partial)
Expand All @@ -76,12 +75,12 @@ def _covered(partial: Partial) -> int:
order_by = functools.partial(_order_by, candidates)
best = max(candidates, key=order_by)

remaining = _uncovered_by(candidates, candidates[best])
to_explore.append((remaining, partial + (best,)))

reduced = _remove_dominated(candidates, best)
to_explore.append((reduced, partial))

Check warning on line 79 in dedupe/branch_and_bound.py

View check run for this annotation

Codecov / codecov/patch

dedupe/branch_and_bound.py#L79

Added line #L79 was not covered by tests

remaining = _uncovered_by(candidates, candidates[best])
to_explore.append((remaining, partial + (best,)))

Check warning on line 82 in dedupe/branch_and_bound.py

View check run for this annotation

Codecov / codecov/patch

dedupe/branch_and_bound.py#L81-L82

Added lines #L81 - L82 were not covered by tests

elif score < cheapest_score:
cheapest = partial
cheapest_score = score
Expand Down

0 comments on commit 3ae13e2

Please sign in to comment.