Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
haifeng-jin committed Nov 4, 2018
1 parent 09d7109 commit 19b8e95
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 61 deletions.
30 changes: 0 additions & 30 deletions tests/image/test_image_supervised.py
Expand Up @@ -60,36 +60,6 @@ def test_timeout():
clean_dir(TEST_TEMP_DIR)


@patch('torch.multiprocessing.Pool', new=MockProcess)
@patch('autokeras.search.ModelTrainer.train_model', side_effect=mock_train)
def test_timeout_resume(_):
Constant.MAX_ITER_NUM = 1
# make it impossible to complete within 10sec
Constant.MAX_MODEL_NUM = 1000
Constant.SEARCH_MAX_ITER = 1
# Constant.T_MIN = 0.8
train_x = np.random.rand(100, 25, 25, 1)
train_y = np.random.randint(0, 5, 100)
test_x = np.random.rand(100, 25, 25, 1)
clean_dir(TEST_TEMP_DIR)
clf = ImageClassifier(path=TEST_TEMP_DIR, verbose=False, resume=False)
clf.n_epochs = 100
clf.fit(train_x, train_y, time_limit=5)
history_len = len(clf.load_searcher().history)
assert history_len != 0
results = clf.predict(test_x)
assert len(results) == 100

clf = ImageClassifier(verbose=False, path=TEST_TEMP_DIR, resume=True)
assert len(clf.load_searcher().history) == history_len
Constant.MAX_MODEL_NUM = history_len + 1
clf.fit(train_x, train_y)
assert len(clf.load_searcher().history) == history_len + 1
results = clf.predict(test_x)
assert len(results) == 100
clean_dir(TEST_TEMP_DIR)


@patch('torch.multiprocessing.Pool', new=MockProcess)
@patch('autokeras.bayesian.transform', side_effect=simple_transform)
@patch('autokeras.search.ModelTrainer.train_model', side_effect=mock_train)
Expand Down
31 changes: 0 additions & 31 deletions tests/text/test_text_supervised.py
Expand Up @@ -49,37 +49,6 @@ def test_timeout(_):
clean_dir(TEST_TEMP_DIR)


@patch('torch.multiprocessing.Pool', new=MockProcess)
@patch('autokeras.text.text_supervised.text_preprocess', side_effect=mock_text_preprocess)
@patch('autokeras.search.ModelTrainer.train_model', side_effect=mock_train)
def test_timeout_resume(_, _1):
Constant.MAX_ITER_NUM = 1
# make it impossible to complete within 10sec
Constant.MAX_MODEL_NUM = 1000
Constant.SEARCH_MAX_ITER = 1
Constant.T_MIN = 0.8
train_x = np.random.rand(100, 25, 25, 1)
train_y = np.random.randint(0, 5, 100)
test_x = np.random.rand(100, 25, 25, 1)
clean_dir(TEST_TEMP_DIR)
clf = TextClassifier(path=TEST_TEMP_DIR, verbose=False, resume=False)
clf.n_epochs = 100
clf.fit(train_x, train_y, time_limit=2)
history_len = len(clf.load_searcher().history)
assert history_len != 0
results = clf.predict(test_x)
assert len(results) == 100

clf = TextClassifier(path=TEST_TEMP_DIR, verbose=False, resume=True)
assert len(clf.load_searcher().history) == history_len
Constant.MAX_MODEL_NUM = history_len + 1
clf.fit(train_x, train_y)
assert len(clf.load_searcher().history) == history_len + 1
results = clf.predict(test_x)
assert len(results) == 100
clean_dir(TEST_TEMP_DIR)


@patch('torch.multiprocessing.Pool', new=MockProcess)
@patch('autokeras.bayesian.transform', side_effect=simple_transform)
@patch('autokeras.search.ModelTrainer.train_model', side_effect=mock_train)
Expand Down

0 comments on commit 19b8e95

Please sign in to comment.