-
Notifications
You must be signed in to change notification settings - Fork 10
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 #43 from IMMM-SFA/feature/tests
Tests to increase coverage of core functionality
- Loading branch information
Showing
20 changed files
with
48,438 additions
and
10 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
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 |
---|---|---|
|
@@ -39,3 +39,4 @@ sklearn>=0.0 | |
threadpoolctl>=3.1.0 | ||
urllib3>=1.26.8 | ||
tqdm>=4.63.0 | ||
fastparquet>=0.8.3 |
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 |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
from .visualization import * | ||
|
||
# Set the current version of TELL: | ||
__version__ = '0.1.3' | ||
__version__ = '0.1.4' |
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
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
8,761 changes: 8,761 additions & 0 deletions
8,761
tell/tests/data/ERCO_WRF_Hourly_Mean_Meteorology_2039.csv
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
39,475 changes: 39,475 additions & 0 deletions
39,475
tell/tests/data/train_data/ERCO_historical_data.csv
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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,21 @@ | ||
import unittest | ||
|
||
import tell | ||
import tell.install_forcing_data as td | ||
|
||
|
||
class TestInstallForcingData(unittest.TestCase): | ||
|
||
def test_instantiate(self): | ||
|
||
zen = td.InstallForcingSample(data_dir="fake") | ||
|
||
# ensure default version is set | ||
self.assertEqual(str, type(zen.DEFAULT_VERSION)) | ||
|
||
# ensure urls present for current version | ||
self.assertTrue(tell.__version__ in zen.DATA_VERSION_URLS) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,21 @@ | ||
import unittest | ||
|
||
import tell | ||
from tell.install_quickstarter_data import InstallQuickstarterData | ||
|
||
|
||
class TestInstallQuickstarterData(unittest.TestCase): | ||
|
||
def test_instantiate(self): | ||
|
||
zen = InstallQuickstarterData(data_dir="fake") | ||
|
||
# ensure default version is set | ||
self.assertEqual(str, type(zen.DEFAULT_VERSION)) | ||
|
||
# ensure urls present for current version | ||
self.assertTrue(tell.__version__ in zen.DATA_VERSION_URLS) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,21 @@ | ||
import unittest | ||
|
||
import tell | ||
import tell.install_raw_data as td | ||
|
||
|
||
class TestInstallRawData(unittest.TestCase): | ||
|
||
def test_instantiate(self): | ||
|
||
zen = td.InstallRawData(data_dir="fake") | ||
|
||
# ensure default version is set | ||
self.assertEqual(str, type(zen.DEFAULT_VERSION)) | ||
|
||
# ensure urls present for current version | ||
self.assertTrue(tell.__version__ in zen.DATA_VERSION_URLS) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,56 @@ | ||
import unittest | ||
import pkg_resources | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
import tell.mlp_train as mp | ||
|
||
|
||
class TestMlpTrain(unittest.TestCase): | ||
"""Tests for functionality within mlp_train.py""" | ||
|
||
COMP_TRAIN_ARR = pd.read_parquet(pkg_resources.resource_filename("tell", "tests/data/comp_train.parquet"))["a"].values | ||
COMP_TRAIN_PRED_DF = pd.read_parquet(pkg_resources.resource_filename("tell", "tests/data/train_data/comp_train_pred.parquet")) | ||
COMP_TRAIN_VALID_DF = pd.read_parquet(pkg_resources.resource_filename("tell", "tests/data/train_data/comp_train_valid.parquet")) | ||
|
||
def test_train_mlp_model(self): | ||
"""Test to ensure high level functionality of predict()""" | ||
|
||
np.random.seed(123) | ||
|
||
arr = mp.train_mlp_model(region="ERCO", | ||
x_train=np.arange(0.1, 100.0, 1.1).reshape(-1, 1), | ||
y_train=np.arange(0.1, 100.0, 1.1).reshape(-1, 1), | ||
x_test=np.arange(0.1, 100.0, 1.1).reshape(-1, 1), | ||
mlp_hidden_layer_sizes=10, | ||
mlp_max_iter=2, | ||
mlp_validation_fraction=0.4) | ||
|
||
np.testing.assert_array_equal(TestMlpTrain.COMP_TRAIN_ARR, arr) | ||
|
||
def test_train(self): | ||
"""Test to ensure high level functionality of train()""" | ||
|
||
np.random.seed(123) | ||
|
||
prediction_df, validation_df = mp.train(region="ERCO", | ||
data_dir=pkg_resources.resource_filename("tell", "tests/data/train_data")) | ||
|
||
pd.testing.assert_frame_equal(TestMlpTrain.COMP_TRAIN_PRED_DF, prediction_df) | ||
pd.testing.assert_frame_equal(TestMlpTrain.COMP_TRAIN_VALID_DF, validation_df) | ||
|
||
def test_train_batch(self): | ||
"""Test to ensure high level functionality of train()""" | ||
|
||
np.random.seed(123) | ||
|
||
prediction_df, validation_df = mp.train_batch(target_region_list=["ERCO"], | ||
data_dir=pkg_resources.resource_filename("tell", "tests/data/train_data")) | ||
|
||
pd.testing.assert_frame_equal(TestMlpTrain.COMP_TRAIN_PRED_DF, prediction_df) | ||
pd.testing.assert_frame_equal(TestMlpTrain.COMP_TRAIN_VALID_DF, validation_df) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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