Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the search for posting matches in extreme cases #224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions beancount_import/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,6 @@ def _get_uncleared_aggregate_posting_candidates(
[]).append(posting)

results = [] # type: List[Posting]
max_subset_size = 4
sum_to_zero = set() # type: Set[Tuple[int, ...]]

def posting_set_id(postings):
Expand Down Expand Up @@ -905,6 +904,7 @@ def add_subset(l, account, currency, subset, check_zero=True):
l.append((aggregate_posting, tuple(subset)))

for (account, currency), posting_list in possible_sets.items():
max_subset_size = 4 if len(posting_list) < 25 else 1
if len(posting_list) == 1:
continue
if len(posting_list) > max_subset_size:
Expand Down Expand Up @@ -1783,8 +1783,9 @@ def do_extend_candidate(transaction: Transaction, level: int):
excluded_transaction_ids=cast(FrozenSet[int],
used_transaction_ids),
debug_level=level):
maybe_extend_candidate(new_transaction, matching_transaction,
level + 1)
if level <= 6:
maybe_extend_candidate(new_transaction, matching_transaction,
level + 1)

maybe_extend_candidate(initial_transaction, initial_transaction, level=0)

Expand Down
Loading