Skip to content

Commit

Permalink
401: refactor to fix sonarqube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Sharples committed Jan 14, 2025
1 parent 09b2567 commit 5d3a099
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/test_ctc_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions test/test_mode_2d_arearat_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
15 changes: 1 addition & 14 deletions test/test_mode_3d_volrat_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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",
[
Expand Down
16 changes: 15 additions & 1 deletion test/utils.py
Original file line number Diff line number Diff line change
@@ -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")
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],
]
)

0 comments on commit 5d3a099

Please sign in to comment.