-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated conf dict file discovery and loading from experiment._from_…
…dict and added tests for the new functions.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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,33 @@ | ||
__author__ = 'mattilyra' | ||
|
||
try: | ||
import cPickle as pickle | ||
except ImportError: | ||
import pickle | ||
|
||
import pytest | ||
|
||
from naklar.experiment import _find_conf_files | ||
from naklar.experiment import _read_conf_dicts | ||
|
||
|
||
@pytest.fixture | ||
def experiment_tree(tmpdir): | ||
for i in xrange(10): | ||
pth = tmpdir.mkdir('exp{}'.format(i)).join('conf.pkl') | ||
d = {'a': 1, 'b': 2} | ||
pth.write(pickle.dumps(d)) | ||
return tmpdir | ||
|
||
|
||
def test_conf_discovery(experiment_tree): | ||
confs = _find_conf_files(experiment_tree.strpath) | ||
assert(len(list(confs)) == 10) | ||
for i, fh in enumerate(confs): | ||
assert(fh.name.endswith('conf.pkl')) | ||
|
||
|
||
def test_conf_dict_load(experiment_tree): | ||
confs = _find_conf_files(experiment_tree.strpath) | ||
dicts = _read_conf_dicts(confs) | ||
assert(len(list(dicts)) == 10) |