def test_rainfarm_aggregate(
    data,
    alpha,
    ds_factor,
    threshold,
    return_alpha,
    spectral_fusion,
    kernel_type,
):
    """Test that the output of rainfarm is equal to original when aggregated."""
    precip, metadata = data
    window = metadata["xpixelsize"] * ds_factor
    precip_lr, __ = aggregate_fields_space(precip, metadata, window)

    rainfarm = downscaling.get_method("rainfarm")
    precip_hr = rainfarm(
        precip_lr,
        alpha=alpha,
        ds_factor=ds_factor,
        threshold=threshold,
        return_alpha=return_alpha,
        spectral_fusion=spectral_fusion,
        kernel_type=kernel_type,
    )
    precip_low = aggregate_fields(precip_hr, ds_factor, axis=(0, 1))
    precip_lr[precip_lr < threshold] = 0.0

    np.testing.assert_array_almost_equal(precip_lr, precip_low)
Test that the output of rainfarm is equal to original when aggregated.
pysteps/tests/test_downscaling_rainfarm.py