Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
severinsimmler committed Sep 1, 2018
1 parent 4068d60 commit 00be421
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
23 changes: 23 additions & 0 deletions tests/test_api.py
@@ -0,0 +1,23 @@
import pytest
import pathlib
import cophi


DOCUMENT = "A B C D E F"

def make_file(tmpdir, fname, content):
p = tmpdir.mkdir("sub").join(fname)
p.write(content)
return p

def test_document(tmpdir):
filepath = make_file(tmpdir, "document.txt", DOCUMENT)
document = cophi.document(str(filepath), token_pattern=r"\w")
assert document.text == DOCUMENT

def test_corpus(tmpdir):
p = make_file(tmpdir, "document.txt", DOCUMENT)
directory = pathlib.Path(str(p)).parent
corpus, metadata = cophi.corpus(directory)
assert metadata["parent"].iloc[0] == str(directory)
assert corpus.documents[0].text == DOCUMENT
4 changes: 1 addition & 3 deletions tests/test_complexity.py
@@ -1,10 +1,9 @@
import collections

import pandas as pd
import pytest

import cophi


P_STAR = 1
Z = 2
NUM_TYPES = 5
Expand All @@ -13,7 +12,6 @@
"tuldava_ln", "brunet_w", "cttr", "summer_s", "sichel_s", "michea_m",
"honore_h", "entropy", "yule_k", "simpson_d", "herdan_vm", "orlov_z"}


@pytest.fixture
def frequency_spectrum():
tokens = ["A", "A", "A", "B", "B", "C", "D", "E"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model.py
Expand Up @@ -2,9 +2,9 @@
import lxml
import numpy as np
import pandas as pd

import cophi


DOCUMENT = "AAABBCCCDEF"
TOKENS = list(DOCUMENT)
LOWERCASE_TOKENS = [token.lower() for token in TOKENS]
Expand Down
13 changes: 5 additions & 8 deletions tests/test_utils.py
@@ -1,9 +1,8 @@
import collections

import pytest

import cophi


PARAGRAPHS = [["A B C D E F", "G H I J K L"]]
DOCUMENT = PARAGRAPHS[0][0]
TOKENS = DOCUMENT.split(" ")
Expand All @@ -27,14 +26,12 @@ def test_segment_fuzzy():
segments = cophi.utils.segment_fuzzy(PARAGRAPHS, 1)
assert list(segments) == [[["A B C D E F"]], [["G H I J K L"]]]

"""
def test_parameter():
parameter = cophi.utils._parameter(TOKENS, "sichel_s")
assert parameter == {"num_types": 6, "freq_spectrum": collections.Counter({1: 6})}
assert len(parameter) == 2
parameter = cophi.utils._parameter(TOKENS, "honore_h")
assert parameter == {'num_types': 6, 'num_tokens': 6, 'freq_spectrum': Counter({1: 6})}
assert len(parameter) == 3
parameter = cophi.utils._parameter(TOKENS, "entropy")
assert parameter ==
assert len(parameter) == 2
parameter = cophi.utils._parameter(TOKENS, "ttr")
assert parameter ==
"""
assert len(parameter) == 2

0 comments on commit 00be421

Please sign in to comment.