Skip to content

Test all functions to ensure inputs unmodified #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions xrspatial/tests/test_zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,21 @@ def test_zonal_stats_against_qgis(elevation_raster_no_nans, raster, qgis_zonal_s
check_results('numpy', xrspatial_df_result, qgis_zonal_stats, atol=1e-5)


@pytest.mark.parametrize("backend", ['numpy', 'dask+numpy', 'cupy'])
def test_zonal_stats_inputs_unmodified(backend, data_zones, data_values_2d, result_default_stats):
if backend == 'cupy' and not has_cuda_and_cupy():
pytest.skip("Requires CUDA and CuPy")

# copy input data to verify they're unchanged after running the function
copied_data_zones = copy.deepcopy(data_zones)
copied_data_values_2d = copy.deepcopy(data_values_2d)

df_result = stats(zones=data_zones, values=data_values_2d)

assert_input_data_unmodified(data_zones, copied_data_zones)
assert_input_data_unmodified(data_values_2d, copied_data_values_2d)


@pytest.mark.parametrize("backend", ['numpy', 'dask+numpy'])
def test_count_crosstab_2d(backend, data_zones, data_values_2d, result_count_crosstab_2d):
# copy input data to verify they're unchanged after running the function
Expand Down