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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ uv run dmypy run # Type checking with mypy
- Never post "update" messages, progress reports, or explanatory comments on
GitHub issues/PRs unless specifically instructed
- When creating commits, always include a co-authorship trailer:
`Co-authored-by: Claude <claude@anthropic.com>`
`Co-authored-by: Claude <noreply@anthropic.com>`
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ module = [
"xarray.tests.test_concat",
"xarray.tests.test_coordinates",
"xarray.tests.test_dask",
"xarray.tests.test_dataarray",
"xarray.tests.test_duck_array_ops",
"xarray.tests.test_indexing",
"xarray.tests.test_merge",
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/scipy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
try:
from scipy.io import netcdf_file as netcdf_file_base
except ImportError:
netcdf_file_base = object
netcdf_file_base = object # type: ignore[assignment,misc,unused-ignore] # scipy is optional


if TYPE_CHECKING:
Expand Down
22 changes: 15 additions & 7 deletions xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_properties(self) -> None:
with pytest.raises(ValueError, match=r"must be 1-dimensional"):
self.ds["foo"].to_index()
with pytest.raises(AttributeError):
self.dv.variable = self.v
self.dv.variable = self.v # type: ignore[misc]

def test_data_property(self) -> None:
array = DataArray(np.zeros((3, 4)))
Expand Down Expand Up @@ -1243,7 +1243,7 @@ def test_head(self) -> None:
self.dv.isel({dim: slice(5) for dim in self.dv.dims}), self.dv.head()
)
with pytest.raises(TypeError, match=r"either dict-like or a single int"):
self.dv.head([3])
self.dv.head([3]) # type: ignore[arg-type]
with pytest.raises(TypeError, match=r"expected integer type"):
self.dv.head(x=3.1)
with pytest.raises(ValueError, match=r"expected positive int"):
Expand All @@ -1260,7 +1260,7 @@ def test_tail(self) -> None:
self.dv.isel({dim: slice(-5, None) for dim in self.dv.dims}), self.dv.tail()
)
with pytest.raises(TypeError, match=r"either dict-like or a single int"):
self.dv.tail([3])
self.dv.tail([3]) # type: ignore[arg-type]
with pytest.raises(TypeError, match=r"expected integer type"):
self.dv.tail(x=3.1)
with pytest.raises(ValueError, match=r"expected positive int"):
Expand All @@ -1273,7 +1273,7 @@ def test_thin(self) -> None:
self.dv.thin(6),
)
with pytest.raises(TypeError, match=r"either dict-like or a single int"):
self.dv.thin([3])
self.dv.thin([3]) # type: ignore[arg-type]
with pytest.raises(TypeError, match=r"expected integer type"):
self.dv.thin(x=3.1)
with pytest.raises(ValueError, match=r"expected positive int"):
Expand Down Expand Up @@ -2206,7 +2206,7 @@ def test_expand_dims_with_greater_dim_size(self) -> None:
assert_identical(other_way_expected, other_way)

def test_set_index(self) -> None:
indexes = [self.mindex.get_level_values(n) for n in self.mindex.names]
indexes = [self.mindex.get_level_values(n) for n in self.mindex.names] # type: ignore[arg-type,unused-ignore] # pandas-stubs varies
coords = {idx.name: ("x", idx) for idx in indexes}
array = DataArray(self.mda.values, coords=coords, dims="x")
expected = self.mda.copy()
Expand Down Expand Up @@ -2237,7 +2237,7 @@ def test_set_index(self) -> None:
obj.set_index(x="level_4")

def test_reset_index(self) -> None:
indexes = [self.mindex.get_level_values(n) for n in self.mindex.names]
indexes = [self.mindex.get_level_values(n) for n in self.mindex.names] # type: ignore[arg-type,unused-ignore] # pandas-stubs varies
coords = {idx.name: ("x", idx) for idx in indexes}
expected = DataArray(self.mda.values, coords=coords, dims="x")

Expand Down Expand Up @@ -2335,10 +2335,18 @@ def test_array_interface(self) -> None:
assert_equal(self.dv, np.maximum(self.dv, bar))

def test_astype_attrs(self) -> None:
for v in [self.va.copy(), self.mda.copy(), self.ds.copy()]:
# Split into two loops for mypy - Variable, DataArray, and Dataset
# don't share a common base class, so mypy infers type object for v,
# which doesn't have the attrs or astype methods
for v in [self.mda.copy(), self.ds.copy()]:
v.attrs["foo"] = "bar"
assert v.attrs == v.astype(float).attrs
assert not v.astype(float, keep_attrs=False).attrs
# Test Variable separately to avoid mypy inferring object type
va = self.va.copy()
va.attrs["foo"] = "bar"
assert va.attrs == va.astype(float).attrs
assert not va.astype(float, keep_attrs=False).attrs

def test_astype_dtype(self) -> None:
original = DataArray([-1, 1, 2, 3, 1000])
Expand Down
Loading