Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,9 @@ module = [
"xarray.tests.test_duck_array_ops",
"xarray.tests.test_indexing",
"xarray.tests.test_merge",
"xarray.tests.test_missing",
"xarray.tests.test_parallelcompat",
"xarray.tests.test_sparse",
"xarray.tests.test_ufuncs",
"xarray.tests.test_units",
"xarray.tests.test_utils",
"xarray.tests.test_variable",
"xarray.tests.test_weighted",
]
Expand Down
13 changes: 7 additions & 6 deletions xarray/tests/test_missing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import itertools
from typing import Any
from unittest import mock

import numpy as np
Expand Down Expand Up @@ -204,7 +205,7 @@ def test_interpolate_unsorted_index_raises():
vals = np.array([1, 2, 3], dtype=np.float64)
expected = xr.DataArray(vals, dims="x", coords={"x": [2, 1, 3]})
with pytest.raises(ValueError, match=r"Index 'x' must be monotonically increasing"):
expected.interpolate_na(dim="x", method="index")
expected.interpolate_na(dim="x", method="index") # type: ignore[arg-type]


def test_interpolate_no_dim_raises():
Expand All @@ -216,14 +217,14 @@ def test_interpolate_no_dim_raises():
def test_interpolate_invalid_interpolator_raises():
da = xr.DataArray(np.array([1, 2, np.nan, 5], dtype=np.float64), dims="x")
with pytest.raises(ValueError, match=r"not a valid"):
da.interpolate_na(dim="x", method="foo")
da.interpolate_na(dim="x", method="foo") # type: ignore[arg-type]


def test_interpolate_duplicate_values_raises():
data = np.random.randn(2, 3)
da = xr.DataArray(data, coords=[("x", ["a", "a"]), ("y", [0, 1, 2])])
with pytest.raises(ValueError, match=r"Index 'x' has duplicate values"):
da.interpolate_na(dim="x", method="foo")
da.interpolate_na(dim="x", method="foo") # type: ignore[arg-type]


def test_interpolate_multiindex_raises():
Expand Down Expand Up @@ -331,15 +332,15 @@ def test_interpolate_limits():
@requires_scipy
def test_interpolate_methods():
for method in ["linear", "nearest", "zero", "slinear", "quadratic", "cubic"]:
kwargs = {}
kwargs: dict[str, Any] = {}
da = xr.DataArray(
np.array([0, 1, 2, np.nan, np.nan, np.nan, 6, 7, 8], dtype=np.float64),
dims="x",
)
actual = da.interpolate_na("x", method=method, **kwargs)
actual = da.interpolate_na("x", method=method, **kwargs) # type: ignore[arg-type]
assert actual.isnull().sum() == 0

actual = da.interpolate_na("x", method=method, limit=2, **kwargs)
actual = da.interpolate_na("x", method=method, limit=2, **kwargs) # type: ignore[arg-type]
assert actual.isnull().sum() == 1


Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_parallelcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __new__(
def __array_finalize__(self, obj):
if obj is None:
return
self.chunks = getattr(obj, "chunks", None)
self.chunks = getattr(obj, "chunks", None) # type: ignore[assignment]

def rechunk(self, chunks, **kwargs):
copied = self.copy()
Expand Down
16 changes: 8 additions & 8 deletions xarray/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def new_method():
pass

old_method = utils.alias(new_method, "old_method")
assert "deprecated" in old_method.__doc__
assert "deprecated" in old_method.__doc__ # type: ignore[operator]
with pytest.warns(Warning, match="deprecated"):
old_method()

Expand Down Expand Up @@ -102,10 +102,10 @@ def test_compat_dict_union(self):
utils.compat_dict_union(self.x, self.z)

def test_dict_equiv(self):
x = {}
x: dict = {}
x["a"] = 3
x["b"] = np.array([1, 2, 3])
y = {}
y: dict = {}
y["b"] = np.array([1.0, 2.0, 3.0])
y["a"] = 3
assert utils.dict_equiv(x, y) # two nparrays are equal
Expand All @@ -129,11 +129,11 @@ def test_dict_equiv(self):
def test_frozen(self):
x = utils.Frozen(self.x)
with pytest.raises(TypeError):
x["foo"] = "bar"
x["foo"] = "bar" # type: ignore[index]
with pytest.raises(TypeError):
del x["a"]
del x["a"] # type: ignore[attr-defined]
with pytest.raises(AttributeError):
x.update(self.y)
x.update(self.y) # type: ignore[attr-defined]
assert x.mapping == self.x
assert repr(x) in (
"Frozen({'a': 'A', 'b': 'B'})",
Expand Down Expand Up @@ -231,11 +231,11 @@ def test_hidden_key_dict():


def test_either_dict_or_kwargs():
result = either_dict_or_kwargs(dict(a=1), None, "foo")
result = either_dict_or_kwargs(dict(a=1), {}, "foo")
expected = dict(a=1)
assert result == expected

result = either_dict_or_kwargs(None, dict(a=1), "foo")
result = either_dict_or_kwargs({}, dict(a=1), "foo")
expected = dict(a=1)
assert result == expected

Expand Down
Loading