forked from fotisj/pydelta
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
""" | ||
A few fixtures usable for many tests. | ||
To speed testing up, all of these fixtures are marked as 'session' fixtures. | ||
Thus, they MUST NOT be modified by the tests. | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
import delta | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def testdir() -> str: | ||
return os.fspath(Path(__file__).parent / 'corpus3') | ||
""" | ||
Test directory with 9 texts from 3 authors | ||
""" | ||
return os.fspath(Path(__file__).parent / 'corpus3') | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def corpus(testdir) -> delta.Corpus: | ||
""" | ||
Raw carpus built from the test directory. | ||
""" | ||
return delta.Corpus(testdir) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def c50(corpus) -> delta.Corpus: | ||
""" | ||
Sample corpus limited to the 50 most frequent words. | ||
""" | ||
c50 = corpus.get_mfw_table(50) | ||
return c50 | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def distances(c50): | ||
""" | ||
A sample distance matrix. | ||
""" | ||
return delta.functions.cosine_delta(c50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import delta | ||
|
||
|
||
def test_issue_6(distances): | ||
clustering = delta.Clustering(distances) | ||
clusters = clustering.fclustering() | ||
print("\nFLAT CLUSTERS\n", clusters.describe()) | ||
print("\nATTEMPTING distances.evaluate()\n") | ||
assert distances.evaluate() is not None | ||
|
||
|
||
def test_dm_zscore(distances): | ||
z_scores = distances.z_scores() | ||
assert z_scores is not None | ||
|
||
|
||
def test_dm_operation(distances): | ||
assert distances - 1 is not None |