diff --git a/xrspatial/tests/test_classify.py b/xrspatial/tests/test_classify.py index 5368239a..1b8e96f5 100644 --- a/xrspatial/tests/test_classify.py +++ b/xrspatial/tests/test_classify.py @@ -208,7 +208,8 @@ def test_natural_breaks_not_enough_unique_values(): agg = input_data() n_uniques = np.isfinite(agg.data).sum() k = n_uniques + 1 - result_natural_breaks = natural_breaks(agg, k=k) + with pytest.warns(Warning): + result_natural_breaks = natural_breaks(agg, k=k) n_uniques_result = np.isfinite(result_natural_breaks.data).sum() np.testing.assert_allclose(n_uniques_result, n_uniques) diff --git a/xrspatial/tests/test_focal.py b/xrspatial/tests/test_focal.py index 1c05d083..49aad383 100644 --- a/xrspatial/tests/test_focal.py +++ b/xrspatial/tests/test_focal.py @@ -457,7 +457,7 @@ def data_hotspots(): def test_hotspots_zero_global_std(): data = np.zeros((10, 20)) agg = create_test_raster(data) - kernel = np.zeros((3, 3)) + kernel = np.ones((3, 3)) msg = "Standard deviation of the input raster values is 0." with pytest.raises(ZeroDivisionError, match=msg): hotspots(agg, kernel) diff --git a/xrspatial/tests/test_pathfinding.py b/xrspatial/tests/test_pathfinding.py index 5858d0c2..0f718e12 100644 --- a/xrspatial/tests/test_pathfinding.py +++ b/xrspatial/tests/test_pathfinding.py @@ -74,6 +74,8 @@ def test_a_star_search_no_barriers(input_data): assert np.nanmin(path_agg) == 0 +@pytest.mark.filterwarnings("ignore:Start at a non crossable location:Warning") +@pytest.mark.filterwarnings("ignore:End at a non crossable location:Warning") def test_a_star_search_with_barriers(input_data): agg = input_data barriers = [1] @@ -92,6 +94,8 @@ def test_a_star_search_with_barriers(input_data): general_output_checks(agg, path_agg, expected_results) +@pytest.mark.filterwarnings("ignore:Start at a non crossable location:Warning") +@pytest.mark.filterwarnings("ignore:End at a non crossable location:Warning") def test_a_star_search_snap(input_data_with_nans): agg, start, goal = input_data_with_nans diff --git a/xrspatial/tests/test_zonal.py b/xrspatial/tests/test_zonal.py index e2bd1f84..326d4077 100644 --- a/xrspatial/tests/test_zonal.py +++ b/xrspatial/tests/test_zonal.py @@ -447,7 +447,8 @@ def test_default_stats_dataarray( assert_input_data_unmodified(data_zones, copied_data_zones) assert_input_data_unmodified(data_values_2d, copied_data_values_2d) - +@pytest.mark.filterwarnings("ignore:All-NaN slice encountered:RuntimeWarning") +@pytest.mark.filterwarnings("ignore:invalid value encountered in divide:RuntimeWarning") @pytest.mark.parametrize("backend", ['numpy', 'dask+numpy', 'cupy']) def test_zone_ids_stats(backend, data_zones, data_values_2d, result_zone_ids_stats, result_zone_ids_stats_no_majority):