diff --git a/improver_tests/wxcode/wxcode/test_ModalCode.py b/improver_tests/wxcode/wxcode/test_ModalCode.py index ac4ac683e5..c490d7e715 100644 --- a/improver_tests/wxcode/wxcode/test_ModalCode.py +++ b/improver_tests/wxcode/wxcode/test_ModalCode.py @@ -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( diff --git a/improver_tests/wxcode/wxcode/test_ModalFromGroupings.py b/improver_tests/wxcode/wxcode/test_ModalFromGroupings.py index 82e5a7c6dc..52f30abfe2 100644 --- a/improver_tests/wxcode/wxcode/test_ModalFromGroupings.py +++ b/improver_tests/wxcode/wxcode/test_ModalFromGroupings.py @@ -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", @@ -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), ),