diff --git a/tests/conftest.py b/tests/conftest.py index bbb87c2a1..9c23755cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -33,8 +33,12 @@ def pytest_configure(config): # pylint: disable=unused-argument # noqa: ARG001 CONFIG_DIR, 'spatiotemporal', 'gen_3x_4x_2f.json' ) pytest.S_FP_GEN = os.path.join(CONFIG_DIR, 'spatial', 'gen_2x_2f.json') - pytest.ST_FP_DISC = os.path.join(CONFIG_DIR, 'spatiotemporal', 'disc.json') - pytest.S_FP_DISC = os.path.join(CONFIG_DIR, 'spatial', 'disc.json') + + # Note that disc should not use "same" zeros padding but easier to use this + # for testing on small sample sizes. + pytest.ST_FP_DISC = os.path.join(TEST_DATA_DIR, 'config_disc_st_test.json') + pytest.S_FP_DISC = os.path.join(TEST_DATA_DIR, 'config_disc_s_test.json') + pytest.FPS_GCM = [ os.path.join(TEST_DATA_DIR, 'ua_test.nc'), os.path.join(TEST_DATA_DIR, 'va_test.nc'), diff --git a/tests/data/config_disc_s_test.json b/tests/data/config_disc_s_test.json new file mode 100644 index 000000000..c1acb7b94 --- /dev/null +++ b/tests/data/config_disc_s_test.json @@ -0,0 +1,24 @@ +{ + "hidden_layers": [ + {"class": "Conv2D", "filters": 32, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 32, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 64, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 64, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 128, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 128, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 256, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv2D", "filters": 256, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Flatten"}, + {"class": "Dense", "units": 1024}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Dense", "units": 1} + ] +} diff --git a/tests/data/config_disc_st_test.json b/tests/data/config_disc_st_test.json new file mode 100644 index 000000000..39083fb49 --- /dev/null +++ b/tests/data/config_disc_st_test.json @@ -0,0 +1,26 @@ +{ + "hidden_layers": [ + {"class": "Conv3D", "filters": 32, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 32, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 64, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 64, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 128, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 128, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 256, "kernel_size": 3, "padding": "same", "strides": 1}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Conv3D", "filters": 256, "kernel_size": 3, "padding": "same", "strides": 2}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Flatten"}, + {"class": "Dense", "units": 2048}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Dense", "units": 1024}, + {"alpha": 0.2, "class": "LeakyReLU"}, + {"class": "Dense", "units": 1} + ] +} diff --git a/tests/training/test_train_exo.py b/tests/training/test_train_exo.py index d3f8fe1e1..ca5b0e9da 100644 --- a/tests/training/test_train_exo.py +++ b/tests/training/test_train_exo.py @@ -7,7 +7,6 @@ import numpy as np import pytest -from sup3r import CONFIG_DIR from sup3r.models import Sup3rGan from sup3r.preprocessing import ( BatchHandler, @@ -65,11 +64,9 @@ def test_wind_hi_res_topo( if mode == 'eager': assert batcher.loaded - fp_disc = os.path.join(CONFIG_DIR, 'spatial/disc.json') - Sup3rGan.seed() model = Sup3rGan( - gen_config_with_topo(CustomLayer), fp_disc, learning_rate=1e-4 + gen_config_with_topo(CustomLayer), pytest.S_FP_DISC, learning_rate=1e-4 ) start = time.time() diff --git a/tests/training/test_train_exo_cc.py b/tests/training/test_train_exo_cc.py index 198a14291..fb3a780ea 100644 --- a/tests/training/test_train_exo_cc.py +++ b/tests/training/test_train_exo_cc.py @@ -57,11 +57,9 @@ def test_wind_hi_res_topo( mode='eager', ) - fp_disc = os.path.join(CONFIG_DIR, 'spatial/disc.json') - Sup3rGan.seed() model = Sup3rGan( - gen_config_with_topo(CustomLayer), fp_disc, learning_rate=1e-4 + gen_config_with_topo(CustomLayer), pytest.S_FP_DISC, learning_rate=1e-4 ) with tempfile.TemporaryDirectory() as td: diff --git a/tests/training/test_train_solar.py b/tests/training/test_train_solar.py index 1ff9d6fef..7888124f9 100644 --- a/tests/training/test_train_solar.py +++ b/tests/training/test_train_solar.py @@ -55,7 +55,7 @@ def test_solar_cc_model(hr_steps): ) fp_gen = os.path.join(CONFIG_DIR, 'sup3rcc/gen_solar_1x_8x_1f.json') - fp_disc = os.path.join(CONFIG_DIR, 'spatiotemporal/disc.json') + fp_disc = pytest.ST_FP_DISC Sup3rGan.seed() model = SolarCC( @@ -127,7 +127,7 @@ def test_solar_cc_model_spatial(): ) fp_gen = os.path.join(CONFIG_DIR, 'sup3rcc/gen_solar_5x_1x_1f.json') - fp_disc = os.path.join(CONFIG_DIR, 'spatial/disc.json') + fp_disc = pytest.S_FP_DISC Sup3rGan.seed() model = Sup3rGan(fp_gen, fp_disc, learning_rate=1e-4) @@ -179,7 +179,7 @@ def test_solar_custom_loss(): ) fp_gen = os.path.join(CONFIG_DIR, 'sup3rcc/gen_solar_1x_8x_1f.json') - fp_disc = os.path.join(CONFIG_DIR, 'spatiotemporal/disc.json') + fp_disc = pytest.ST_FP_DISC Sup3rGan.seed() model = SolarCC(