Skip to content

Commit

Permalink
Time the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleswing committed May 12, 2017
1 parent 7164be0 commit c0b143b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- pip install coveralls
- python setup.py install
script:
- nosetests --with-coverage --cover-package=deepchem -v deepchem --nologcapture
- nosetests --with-timer --with-coverage --cover-package=deepchem -v deepchem --nologcapture
- find ./deepchem | grep .py$ |xargs python -m doctest -v
- bash devtools/travis-ci/test_format_code.sh
after_success:
Expand Down
30 changes: 12 additions & 18 deletions deepchem/utils/test/test_generator_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import numpy as np
from nose.tools import assert_true, with_setup
from nose.tools import assert_true, attr
from unittest import TestCase

import deepchem as dc
from deepchem.data import NumpyDataset
from deepchem.data.datasets import Databag
from deepchem.models.tensorgraph.layers import Dense, ReduceMean, SoftMax, \
SoftMaxCrossEntropy, L2Loss
from deepchem.models.tensorgraph.layers import Dense, ReduceMean, SoftMax, SoftMaxCrossEntropy, L2Loss
from deepchem.models.tensorgraph.layers import Feature, Label
from deepchem.models.tensorgraph.layers import ReduceSquareDifference

RANDOM_SEED = 42


def set_random_seeds():
np.random.seed(RANDOM_SEED)


class TestGeneratorEvaluator(TestCase):

@with_setup(set_random_seeds)
@attr('slow')
def test_compute_model_performance_multitask_classifier(self):
n_data_points = 20
n_features = 2
Expand Down Expand Up @@ -55,7 +48,7 @@ def test_compute_model_performance_multitask_classifier(self):

total_loss = ReduceMean(in_layers=entropies)

tg = dc.models.TensorGraph(learning_rate=0.1, random_seed=RANDOM_SEED)
tg = dc.models.TensorGraph(learning_rate=0.1)
for output in outputs:
tg.add_output(output)
tg.set_loss(total_loss)
Expand All @@ -72,7 +65,7 @@ def test_compute_model_performance_multitask_classifier(self):
# Loosening atol to see if tests stop failing sporadically
assert_true(np.all(np.isclose(scores, [1.0, 1.0], atol=0.50)))

@with_setup(set_random_seeds)
@attr('slow')
def test_compute_model_performance_singletask_classifier(self):
n_data_points = 20
n_features = 10
Expand Down Expand Up @@ -107,7 +100,7 @@ def test_compute_model_performance_singletask_classifier(self):

total_loss = ReduceMean(in_layers=entropies)

tg = dc.models.TensorGraph(learning_rate=0.1, random_seed=RANDOM_SEED)
tg = dc.models.TensorGraph(learning_rate=0.1)
for output in outputs:
tg.add_output(output)
tg.set_loss(total_loss)
Expand All @@ -123,10 +116,12 @@ def test_compute_model_performance_singletask_classifier(self):
scores = list(scores[1].values())
assert_true(np.isclose(scores, [1.0], atol=0.05))

@with_setup(set_random_seeds)
@attr('slow')
def test_compute_model_performance_multitask_regressor(self):
random_seed = 42
n_data_points = 20
n_features = 2
np.random.seed(seed=random_seed)

X = np.random.rand(n_data_points, n_features)
y1 = np.expand_dims(np.array([0.5 for x in range(n_data_points)]), axis=-1)
Expand Down Expand Up @@ -157,7 +152,7 @@ def test_compute_model_performance_multitask_regressor(self):
tg = dc.models.TensorGraph(
mode="regression",
batch_size=20,
random_seed=RANDOM_SEED,
random_seed=random_seed,
learning_rate=0.1)
for output in outputs:
tg.add_output(output)
Expand All @@ -175,7 +170,7 @@ def test_compute_model_performance_multitask_regressor(self):
scores = list(scores[1].values())
assert_true(np.all(np.isclose(scores, [0.0, 0.0], atol=1.0)))

@with_setup(set_random_seeds)
@attr('slow')
def test_compute_model_performance_singletask_regressor(self):
n_data_points = 20
n_features = 2
Expand Down Expand Up @@ -205,8 +200,7 @@ def test_compute_model_performance_singletask_regressor(self):

total_loss = ReduceMean(in_layers=losses)

tg = dc.models.TensorGraph(
mode="regression", learning_rate=0.1, random_seed=RANDOM_SEED)
tg = dc.models.TensorGraph(mode="regression", learning_rate=0.1)
for output in outputs:
tg.add_output(output)
tg.set_loss(total_loss)
Expand Down
1 change: 1 addition & 0 deletions scripts/install_deepchem_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ conda install -y -c pillow
conda install -y -c anaconda pandas=0.19.2
yes | pip install $tensorflow==1.0.1
yes | pip install nose
yes | pip install nose-timer

0 comments on commit c0b143b

Please sign in to comment.