-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
1 parent
a51a830
commit 683c1b1
Showing
4 changed files
with
77 additions
and
76 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 |
---|---|---|
@@ -1,22 +1,38 @@ | ||
from unittest import mock | ||
|
||
from autokeras.tasks import image | ||
import autokeras as ak | ||
from tests import utils | ||
|
||
|
||
@mock.patch('autokeras.auto_model.AutoModel.__init__') | ||
def test_image_classifier(auto_model, tmp_path): | ||
image.ImageClassifier(directory=tmp_path, max_trials=2, seed=utils.SEED) | ||
assert auto_model.called | ||
@mock.patch('autokeras.AutoModel.fit') | ||
def test_img_clf_fit_call_auto_model_fit(fit, tmp_path): | ||
auto_model = ak.ImageClassifier(directory=tmp_path, seed=utils.SEED) | ||
|
||
auto_model.fit( | ||
x=utils.generate_data(num_instances=100, shape=(32, 32, 3)), | ||
y=utils.generate_one_hot_labels(num_instances=100, num_classes=10)) | ||
|
||
@mock.patch('autokeras.auto_model.AutoModel.__init__') | ||
def test_image_regressor(auto_model, tmp_path): | ||
image.ImageRegressor(directory=tmp_path, max_trials=2, seed=utils.SEED) | ||
assert auto_model.called | ||
assert fit.is_called | ||
|
||
|
||
@mock.patch('autokeras.auto_model.AutoModel.__init__') | ||
def test_image_segmenter(auto_model, tmp_path): | ||
image.ImageSegmenter(directory=tmp_path, max_trials=2, seed=utils.SEED) | ||
assert auto_model.called | ||
@mock.patch('autokeras.AutoModel.fit') | ||
def test_img_reg_fit_call_auto_model_fit(fit, tmp_path): | ||
auto_model = ak.ImageRegressor(directory=tmp_path, seed=utils.SEED) | ||
|
||
auto_model.fit( | ||
x=utils.generate_data(num_instances=100, shape=(32, 32, 3)), | ||
y=utils.generate_data(num_instances=100, shape=(1,))) | ||
|
||
assert fit.is_called | ||
|
||
|
||
@mock.patch('autokeras.AutoModel.fit') | ||
def test_img_seg_fit_call_auto_model_fit(fit, tmp_path): | ||
auto_model = ak.tasks.image.ImageSegmenter( | ||
directory=tmp_path, seed=utils.SEED) | ||
|
||
auto_model.fit( | ||
x=utils.generate_data(num_instances=100, shape=(32, 32, 3)), | ||
y=utils.generate_data(num_instances=100, shape=(32, 32))) | ||
|
||
assert fit.is_called |
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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
from unittest import mock | ||
|
||
from autokeras.tasks import text | ||
import numpy as np | ||
|
||
import autokeras as ak | ||
from tests import utils | ||
|
||
|
||
@mock.patch('autokeras.auto_model.AutoModel.__init__') | ||
def test_text_classifier(auto_model, tmp_path): | ||
text.TextClassifier(directory=tmp_path, max_trials=2, seed=utils.SEED) | ||
assert auto_model.called | ||
@mock.patch('autokeras.AutoModel.fit') | ||
def test_txt_clf_fit_call_auto_model_fit(fit, tmp_path): | ||
auto_model = ak.TextClassifier(directory=tmp_path, seed=utils.SEED) | ||
|
||
auto_model.fit( | ||
x=np.array(['a b c', 'b b c']), | ||
y=np.array([1, 2])) | ||
|
||
assert fit.is_called | ||
|
||
|
||
@mock.patch('autokeras.AutoModel.fit') | ||
def test_txt_reg_fit_call_auto_model_fit(fit, tmp_path): | ||
auto_model = ak.TextRegressor(directory=tmp_path, seed=utils.SEED) | ||
|
||
auto_model.fit( | ||
x=np.array(['a b c', 'b b c']), | ||
y=np.array([1.0, 2.0])) | ||
|
||
@mock.patch('autokeras.auto_model.AutoModel.__init__') | ||
def test_text_regressor(auto_model, tmp_path): | ||
text.TextRegressor(directory=tmp_path, max_trials=2, seed=utils.SEED) | ||
assert auto_model.called | ||
assert fit.is_called |