Skip to content

Commit 0b0791b

Browse files
max-sixtyclaudepre-commit-ci[bot]
authored
Further warning exclusion cleanup and test improvements (#10693)
* Remove obsolete warning exclusions from pyproject.toml Removed 11 warning exclusions that are no longer needed: - Invalid cast warnings from duck_array_ops and test_array_api - CachingFileManager deallocation warnings from backends - Deprecated treenode methods (ancestors, iter_lineage, lineage) - Test-specific deprecations that no longer exist These exclusions were verified to be safe to remove through testing. The test suite passes with 20,779 tests after removal. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Remove additional obsolete UserWarning exclusions Removed 3 more warning exclusions that are no longer needed: - UserWarning from test_coding_times - UserWarning from test_computation - UserWarning from test_dataset All test files pass without these warning exclusions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Remove 3 more obsolete warning exclusions Removed warning exclusions that are no longer needed: - "No index created" UserWarning - Tests properly handle with pytest.warns - "pandas.MultiIndex" FutureWarning - No longer triggered - "Duplicate dimension names" UserWarning - Tests handle with local filterwarnings These warnings are either properly tested or no longer occur. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Use pytest.warns consistently for quantile interpolation deprecation Fixed test_dataset.py to use pytest.warns instead of warnings.catch_warnings for testing the interpolation->method deprecation warning. This makes it consistent with the other test files. Note: We cannot remove the global warning exclusion because the error:::xarray.* rule converts warnings to errors before pytest.warns can catch them. This is a known limitation of the current filterwarnings configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Add local filterwarnings to quantile interpolation deprecation tests Instead of relying on a global warning exclusion, added @pytest.mark.filterwarnings decorators to the specific tests that test the interpolation->method deprecation warning. This allows the warning to be properly tested while avoiding the conflict with the error:::xarray.* rule. Now the global exclusion for this warning can be safely removed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Claude <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bd2a035 commit 0b0791b

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,11 @@ addopts = [
358358

359359
filterwarnings = [
360360
"error:::xarray.*",
361-
"default:No index created:UserWarning:xarray.core.dataset",
362-
"default::UserWarning:xarray.tests.test_coding_times",
363-
"default::UserWarning:xarray.tests.test_computation",
364-
"default::UserWarning:xarray.tests.test_dataset",
365361
"default:Failed to decode variable.*NumPy will stop allowing conversion of out-of-bound Python integers to integer arrays:DeprecationWarning",
366-
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning:xarray.*",
367362
"default:invalid value encountered in cast:RuntimeWarning:xarray.conventions",
368363
"default:invalid value encountered in cast:RuntimeWarning:xarray.tests.test_units",
369364
"default:NumPy will stop allowing conversion of:DeprecationWarning",
370-
"default:the `pandas.MultiIndex` object:FutureWarning:xarray.tests.test_variable",
371365
"default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning",
372-
"default:Duplicate dimension names present:UserWarning:xarray.namedarray.core",
373366
# Zarr 2 V3 implementation
374367
"ignore:Zarr-Python is not in alignment with the final V3 specification",
375368
# TODO: this is raised for vlen-utf8, consolidated metadata, U1 dtype

xarray/tests/test_dataarray.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,9 @@ def test_quantile_method(self, method) -> None:
30283028

30293029
np.testing.assert_allclose(actual.values, expected)
30303030

3031+
@pytest.mark.filterwarnings(
3032+
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning"
3033+
)
30313034
@pytest.mark.parametrize("method", ["midpoint", "lower"])
30323035
def test_quantile_interpolation_deprecated(self, method) -> None:
30333036
da = DataArray(self.va)

xarray/tests/test_dataset.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6161,17 +6161,20 @@ def test_quantile_method(self, method) -> None:
61616161
assert_identical(result.var2, ds.var2.quantile(q, method=method))
61626162
assert_identical(result.var3, ds.var3.quantile(q, method=method))
61636163

6164+
@pytest.mark.filterwarnings(
6165+
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning"
6166+
)
61646167
@pytest.mark.parametrize("method", ["midpoint", "lower"])
61656168
def test_quantile_interpolation_deprecated(self, method) -> None:
61666169
ds = create_test_data(seed=123)
61676170
q = [0.25, 0.5, 0.75]
61686171

6169-
with warnings.catch_warnings(record=True) as w:
6172+
with pytest.warns(
6173+
FutureWarning,
6174+
match="`interpolation` argument to quantile was renamed to `method`",
6175+
):
61706176
ds.quantile(q, interpolation=method)
61716177

6172-
# ensure the warning is only raised once
6173-
assert len(w) == 1
6174-
61756178
with warnings.catch_warnings(record=True):
61766179
with pytest.raises(TypeError, match="interpolation and method keywords"):
61776180
ds.quantile(q, method=method, interpolation=method)

xarray/tests/test_groupby.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ def test_ds_groupby_quantile() -> None:
565565
assert_identical(expected, actual)
566566

567567

568+
@pytest.mark.filterwarnings(
569+
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning"
570+
)
568571
@pytest.mark.parametrize("as_dataset", [False, True])
569572
def test_groupby_quantile_interpolation_deprecated(as_dataset: bool) -> None:
570573
array = xr.DataArray(data=[1, 2, 3, 4], coords={"x": [1, 1, 2, 2]}, dims="x")

xarray/tests/test_variable.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,9 @@ def test_quantile_method(self, method, use_dask) -> None:
19281928

19291929
np.testing.assert_allclose(actual.values, expected)
19301930

1931+
@pytest.mark.filterwarnings(
1932+
"default:The `interpolation` argument to quantile was renamed to `method`:FutureWarning"
1933+
)
19311934
@pytest.mark.parametrize("method", ["midpoint", "lower"])
19321935
def test_quantile_interpolation_deprecation(self, method) -> None:
19331936
v = Variable(["x", "y"], self.d)

0 commit comments

Comments
 (0)