def test_aggregate_fields(data, window_size, axis, method, expected):
    """
    Test the aggregate_fields function.
    The windows size must divide exactly the data dimensions.
    Internally, additional test are generated for situations where the
    windows size does not divide the data dimensions.
    The length of each dimension should be larger than 2.
    """

    assert_array_equal(
        dimension.aggregate_fields(data, window_size, axis=axis, method=method),
        expected,
    )

    # Test the trimming capabilities.
    data = np.pad(data, (0, 1))
    assert_array_equal(
        dimension.aggregate_fields(
            data, window_size, axis=axis, method=method, trim=True
        ),
        expected,
    )

    with raises(ValueError):
        dimension.aggregate_fields(data, window_size, axis=axis, method=method)
Test the aggregate_fields function.
The windows size must divide exactly the data dimensions.
Internally, additional test are generated for situations where the
windows size does not divide the data dimensions.
The length of each dimension should be larger than 2.
pysteps/tests/test_utils_dimension.py