Skip to content

Commit

Permalink
FIX python 2 vector
Browse files Browse the repository at this point in the history
  • Loading branch information
hayd committed Dec 11, 2014
1 parent 0c5f92d commit 466f210
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pattern/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ def csv_header_encode(field, type=STRING):
# csv_header_encode("age", INTEGER) => "age (INTEGER)".
t = re.sub(r"^varchar\(.*?\)", "string", (type or ""))
t = t and " (%s)" % t or ""
s = "%s%s" % (encode_utf8(field or ""), t.upper())
s = "%s%s" % (field or "", t.upper())
return s


Expand Down
2 changes: 1 addition & 1 deletion pattern/vector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def _repr(self):
self.type and ", type=%s" % repr(self.type) or "")

def __repr__(self):
return "Document(id=%s%s%s)" % self._repr()
return "Document(id=%s)" % self._repr()

def __hash__(self):
return hash(self._repr())
Expand Down
3 changes: 2 additions & 1 deletion test/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ def test_frequent_concept_sets(self):
# Assert Apriori algorithm.
v = self.model.frequent(threshold=0.5)
self.assertEqual(
sorted(v.keys()), [frozenset(["cats"]), frozenset(["dogs"])])
sorted(v.keys(), key=lambda x: str(x)),
[frozenset(["cats"]), frozenset(["dogs"])])
print("pattern.vector.Model.frequent()")

def test_cosine_similarity(self):
Expand Down

0 comments on commit 466f210

Please sign in to comment.