Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Feb 21, 2024
1 parent 9263984 commit 27add8f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions acoustid/data/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ def __init__(
self.fast = fast
self.timeout = timeout

def _create_search_query(self, length: int, condition: Any, max_results: Optional[int], compare_to: Optional[List[int]] = None) -> Any:
def _create_search_query(
self,
length: int,
condition: Any,
max_results: Optional[int],
compare_to: Optional[List[int]] = None,
) -> Any:
# construct the subquery
f_columns: List[Any] = [
schema.fingerprint.c.id,
Expand Down Expand Up @@ -148,13 +154,17 @@ def _get_max_indexed_fingerprint_id(self, index):
# type: (Index) -> int
return int(index.get_attribute("max_document_id") or "0")

def _search_via_fpstore(self, fp: List[int], length: int, max_results: Optional[int] = None) -> List[FingerprintMatch]:
def _search_via_fpstore(
self, fp: List[int], length: int, max_results: Optional[int] = None
) -> List[FingerprintMatch]:
assert self.fpstore is not None

if max_results is None:
max_results = 100

matching_fingerprints = self.fpstore.search(fp, limit=max_results, fast_mode=self.fast)
matching_fingerprints = self.fpstore.search(
fp, limit=max_results, fast_mode=self.fast
)
if not matching_fingerprints:
return []

Expand All @@ -163,7 +173,9 @@ def _search_via_fpstore(self, fp: List[int], length: int, max_results: Optional[
matching_fingerprint_ids[m.fingerprint_id] = m.score

query = self._create_search_query(
length, schema.fingerprint.c.id.in_(matching_fingerprint_ids.keys()), max_results=max_results
length,
schema.fingerprint.c.id.in_(matching_fingerprint_ids.keys()),
max_results=max_results,
)
if self.timeout:
timeout_ms = int(self.timeout * 1000)
Expand All @@ -182,7 +194,9 @@ def _search_via_fpstore(self, fp: List[int], length: int, max_results: Optional[
matches.append(match)
return matches

def search(self, fp: List[int], length: int, max_results: Optional[int] = None) -> List[FingerprintMatch]:
def search(
self, fp: List[int], length: int, max_results: Optional[int] = None
) -> List[FingerprintMatch]:
if self.fpstore is not None:
return self._search_via_fpstore(fp, length, max_results)

Expand Down

0 comments on commit 27add8f

Please sign in to comment.