diff --git a/test/test_ctc_statistics.py b/test/test_ctc_statistics.py index 1328d5e6..684bda4d 100644 --- a/test/test_ctc_statistics.py +++ b/test/test_ctc_statistics.py @@ -148,7 +148,7 @@ def ctc_data(): return df.to_numpy(), np.array(df.columns) -# TODO: Some of the functions here that +# Some of the functions here that # are evaluating to None could be better # tested with a different dataset. e.g. acc # needs a 'total' column in the test data. diff --git a/test/test_mode_2d_arearat_statistics.py b/test/test_mode_2d_arearat_statistics.py index 5a103de4..b7db41ce 100644 --- a/test/test_mode_2d_arearat_statistics.py +++ b/test/test_mode_2d_arearat_statistics.py @@ -2,6 +2,7 @@ from unittest.mock import patch import numpy as np import metcalcpy.util.mode_2d_arearat_statistics as m2as +from test.utils import MODE_TEST_DATA as data column_names = np.array( ["object_type", "area", "fcst_flag", "simple_flag", "matched_flag"] diff --git a/test/test_mode_3d_volrat_statistics.py b/test/test_mode_3d_volrat_statistics.py index a8a7ae03..f3a9cdd5 100644 --- a/test/test_mode_3d_volrat_statistics.py +++ b/test/test_mode_3d_volrat_statistics.py @@ -2,6 +2,7 @@ from unittest.mock import patch import numpy as np import metcalcpy.util.mode_3d_volrat_statistics as m3vs +from test.utils import MODE_TEST_DATA as data_complex column_names = np.array( ["object_type", "volume", "fcst_flag", "simple_flag", "matched_flag"] @@ -16,20 +17,6 @@ ) -data_complex = np.array( - [ - ["3d", 100, 1, 1, 1], - ["3d", 30, 0, 1, 1], - ["3d", 120, 1, 1, 0], - ["3d", 12, 0, 1, 1], - ["3d", 1, 1, 0, 1], - ["3d", 17, 0, 1, 1], - ["2d", 200, 1, 1, 1], - ["3d", 66, 0, 1, 0], - ] -) - - @pytest.mark.parametrize( "func_name,data_values,expected", [ diff --git a/test/utils.py b/test/utils.py index c52e0636..8094ebfd 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1,8 +1,22 @@ from pathlib import Path +import numpy as np def abs_path(rel_path): """Turn a relative path into abs path""" return str(Path(str(Path(__file__).parents[2])) / rel_path) # Datafile access -AGG_STAT_AND_BOOT_DATA = abs_path("METcalcpy/test/data/agg_stat_and_boot_data.data") \ No newline at end of file +AGG_STAT_AND_BOOT_DATA = abs_path("METcalcpy/test/data/agg_stat_and_boot_data.data") + +MODE_TEST_DATA = np.array( + [ + ["3d", 100, 1, 1, 1], + ["3d", 30, 0, 1, 1], + ["3d", 120, 1, 1, 0], + ["3d", 12, 0, 1, 1], + ["3d", 1, 1, 0, 1], + ["3d", 17, 0, 1, 1], + ["2d", 200, 1, 1, 1], + ["3d", 66, 0, 1, 0], + ] +)