Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcinnes committed Jun 25, 2020
2 parents c01ddc7 + 3d655a8 commit 5c67a32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions vectorizers/_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ def __init__(
window_function="fixed",
kernel_function="flat",
window_radius=5,
window_orientation="symmetric",
window_orientation="directional",
validate_data=True,
):
self.token_dictionary = token_dictionary
Expand Down Expand Up @@ -1317,12 +1317,12 @@ def fit_transform(self, X, y=None, **fit_params):
self.column_index_dictionary_ = self.token_index_dictionary_
elif self.window_orientation == "directional":
self.column_label_dictionary_ = {
"pre_" + token: index
"pre_" + str(token): index
for token, index in self.token_label_dictionary_.items()
}
self.column_label_dictionary_.update(
{
"post_" + token: index + len(self.token_label_dictionary_)
"post_" + str(token): index + len(self.token_label_dictionary_)
for token, index in self.token_label_dictionary_.items()
}
)
Expand Down Expand Up @@ -1472,7 +1472,7 @@ def __init__(
kernel_function="flat",
window_radius=5,
token_dictionary=None,
window_orientation="symmetric",
window_orientation="directional",
validate_data=True,
):
self.token_dictionary = token_dictionary
Expand Down
6 changes: 3 additions & 3 deletions vectorizers/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_LabeledTreeCooccurrenceVectorizer_reduced_vocab():
@pytest.mark.parametrize("max_token_occurrences", [None, 2])
@pytest.mark.parametrize("min_document_occurrences", [None, 1])
@pytest.mark.parametrize("max_document_frequency", [None, 0.7])
@pytest.mark.parametrize("window_orientation", ["before", "after", "symmetric"])
@pytest.mark.parametrize("window_orientation", ["before", "after", "symmetric", "directional"])
@pytest.mark.parametrize("window_radius", [1, 2])
@pytest.mark.parametrize("kernel_function", ["harmonic", "flat"])
def test_equality_of_CooccurrenceVectorizers(
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_find_boundaries_all_dupes():


def test_token_cooccurrence_vectorizer_basic():
vectorizer = TokenCooccurrenceVectorizer()
vectorizer = TokenCooccurrenceVectorizer(window_orientation='symmetric')
result = vectorizer.fit_transform(token_data)
transform = vectorizer.transform(token_data)
assert (result != transform).nnz == 0
Expand Down Expand Up @@ -365,7 +365,7 @@ def test_token_cooccurrence_vectorizer_column_order():


def test_token_cooccurrence_vectorizer_transform():
vectorizer = TokenCooccurrenceVectorizer()
vectorizer = TokenCooccurrenceVectorizer(window_orientation='symmetric')
result = vectorizer.fit_transform(text_token_data_subset)
transform = vectorizer.transform(text_token_data)
assert result.shape == transform.shape
Expand Down

0 comments on commit 5c67a32

Please sign in to comment.