Skip to content

Commit 44a1d73

Browse files
committed
Fix functools ImportError on python 2.7
In python2.7 lru_cache is available in functools32 library.
1 parent 17d6788 commit 44a1d73

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lsh/minhash.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# -*- coding: utf-8 -*-
2-
import json
3-
from copy import deepcopy
4-
from functools import lru_cache
2+
try:
3+
from functools import lru_cache
4+
except ImportError:
5+
from functools32 import lru_cache
56

67
import numpy as np
78

@@ -67,10 +68,9 @@ def jaccard(self, doc1, doc2):
6768
if isinstance(doc1, str):
6869
f_a = set(self.fingerprint(doc1))
6970
else:
70-
f_a = doc1 # assume it's z fingerprint
71+
f_a = doc1 # assume it's z fingerprint
7172
if isinstance(doc1, str):
7273
f_b = set(self.fingerprint(doc2))
7374
else:
7475
f_b = doc2
7576
return len(f_a & f_b) / len(f_a | f_b)
76-

0 commit comments

Comments
 (0)