Skip to content

Commit

Permalink
Add another unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinevans committed Aug 12, 2024
1 parent 1496469 commit cf5e063
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
11 changes: 7 additions & 4 deletions improver_tests/wxcode/wxcode/test_ModalCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ def wxcode_series_fixture(
wxfrt = time - timedelta(hours=42)
wxdata = np.ones((2, 2), dtype=np.int8)

if len(data[i].shape) == 0:
index = 0
if len(data[i].shape) > 0 and np.product(wxdata.shape) == data[i].shape[0]:
wxdata = np.reshape(data[i], wxdata.shape)
else:
index = slice(None, len(data[i]))
wxdata[0, index] = data[i]
if len(data[i].shape) == 0:
index = 0
else:
index = slice(None, len(data[i]))
wxdata[0, index] = data[i]

if cube_type == "gridded":
wxcubes.append(
Expand Down
14 changes: 12 additions & 2 deletions improver_tests/wxcode/wxcode/test_ModalFromGroupings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@


@pytest.mark.parametrize("record_run_attr", [False])
@pytest.mark.parametrize("model_id_attr", [False, True])
@pytest.mark.parametrize("model_id_attr", [True])
@pytest.mark.parametrize("interval", [1])
@pytest.mark.parametrize("offset_reference_times", [False, True])
@pytest.mark.parametrize("offset_reference_times", [True])
@pytest.mark.parametrize("cube_type", ["gridded", "spot"])
@pytest.mark.parametrize(
"data, expected",
Expand Down Expand Up @@ -121,6 +121,16 @@
([0, 0, 0, 2, 2, 0, 10, 10, 11, 12, 13], 1),
# Two locations with different modal dry codes.
([[3, 3, 3, 4, 5, 5], [3, 3, 4, 4, 4, 5]], [3, 4]),
# Four locations with different modal dry codes.
(
[
[3, 3, 3, 4, 5, 5],
[3, 3, 4, 4, 4, 5],
[1, 1, 3, 3, 5, 6],
[6, 6, 6, 7, 7, 7],
],
[3, 4, 3, 7],
),
# Tied dry weather codes. The highest index weather code should be selected.
([0, 0, 0, 2, 2, 2, 7, 7], 3),
),
Expand Down

0 comments on commit cf5e063

Please sign in to comment.