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
2 changed files
with
36 additions
and
2 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
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,34 @@ | ||
""" | ||
Tests for apyori.dump_as_two_item_tsv. | ||
""" | ||
|
||
# For Python 2 compatibility. | ||
try: | ||
from StringIO import StringIO | ||
except ImportError: | ||
from io import StringIO | ||
|
||
from nose.tools import eq_ | ||
|
||
from apyori import RelationRecord | ||
from apyori import OrderedStatistic | ||
from apyori import dump_as_two_item_tsv | ||
|
||
|
||
def test_normal(): | ||
""" | ||
Test for normal data. | ||
""" | ||
test_data = RelationRecord( | ||
frozenset(['A', 'B']), 0.5, [ | ||
OrderedStatistic(frozenset(['A']), frozenset(['B']), 0.8, 1.2), | ||
OrderedStatistic(frozenset(), frozenset(['B']), 0.8, 1.2), | ||
OrderedStatistic(frozenset(['A']), frozenset(), 0.8, 1.2), | ||
] | ||
) | ||
output_file = StringIO() | ||
dump_as_two_item_tsv(test_data, output_file) | ||
|
||
output_file.seek(0) | ||
result = output_file.read() | ||
eq_(result, 'A\tB\t0.50000000\t0.80000000\t1.20000000\n') |