-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from tqtg/master
Add tests for base_strategy and ratio
- Loading branch information
Showing
6 changed files
with
102 additions
and
11 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
Empty file.
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 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
@author: Quoc-Tuan Truong <tuantq.vnu@gmail.com> | ||
""" | ||
|
||
from ..base_strategy import BaseStrategy | ||
|
||
|
||
def test_init(): | ||
bs = BaseStrategy(None, verbose=True) | ||
|
||
assert not bs.exclude_unknowns | ||
assert 1. == bs.rating_threshold | ||
|
||
|
||
def test_trainset_none(): | ||
bs = BaseStrategy(None, verbose=True) | ||
|
||
try: | ||
bs.evaluate(None, {}, False) | ||
except ValueError: | ||
assert True | ||
|
||
|
||
def test_testset_none(): | ||
bs = BaseStrategy(None, train_set=[], verbose=True) | ||
|
||
try: | ||
bs.evaluate(None, {}, False) | ||
except ValueError: | ||
assert True | ||
|
||
|
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,49 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
@author: Quoc-Tuan Truong <tuantq.vnu@gmail.com> | ||
""" | ||
|
||
from ..ratio_split import RatioSplit | ||
|
||
|
||
def test_validate_size(): | ||
train_size, val_size, test_size = RatioSplit._validate_sizes(0.1, 0.2, 10) | ||
assert 7 == train_size | ||
assert 1 == val_size | ||
assert 2 == test_size | ||
|
||
train_size, val_size, test_size = RatioSplit._validate_sizes(None, 0.5, 10) | ||
assert 5 == train_size | ||
assert 0 == val_size | ||
assert 5 == test_size | ||
|
||
train_size, val_size, test_size = RatioSplit._validate_sizes(None, None, 10) | ||
assert 10 == train_size | ||
assert 0 == val_size | ||
assert 0 == test_size | ||
|
||
train_size, val_size, test_size = RatioSplit._validate_sizes(2, 2, 10) | ||
assert 6 == train_size | ||
assert 2 == val_size | ||
assert 2 == test_size | ||
|
||
try: | ||
RatioSplit._validate_sizes(-1, 0.2, 10) | ||
except ValueError: | ||
assert True | ||
|
||
try: | ||
RatioSplit._validate_sizes(11, 0.2, 10) | ||
except ValueError: | ||
assert True | ||
|
||
try: | ||
RatioSplit._validate_sizes(0, 11, 10) | ||
except ValueError: | ||
assert True | ||
|
||
try: | ||
RatioSplit._validate_sizes(3, 8, 10) | ||
except ValueError: | ||
assert True |
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