Skip to content

Fix mypy, min-versions CI, xfail Zarr tests #10255

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 4 commits into from
Apr 26, 2025
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
12 changes: 11 additions & 1 deletion ci/minimum_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

channels = ["conda-forge"]
platforms = ["noarch", "linux-64"]
# these packages don't fail the CI, but will be printed in the report
ignore_failure_packages = [
# remove when we can pin to pydap 3.5.1 without error
"pydap",
]
# these packages are completely ignored
ignored_packages = [
"coveralls",
"pip",
Expand Down Expand Up @@ -171,7 +177,11 @@ def compare_versions(environments, policy_versions):
status = {}
for env, specs in environments.items():
env_status = any(
spec.version > policy_versions[spec.name].version for spec in specs
(
(spec.version > policy_versions[spec.name].version)
and (spec.name not in ignore_failure_packages)
)
for spec in specs
)
status[env] = env_status
return status
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies:
- pandas=2.1
- pint=0.22
- pip
- pydap=3.5.0
- pydap=3.5
- pytest
- pytest-cov
- pytest-env
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ filterwarnings = [
"default:the `pandas.MultiIndex` object:FutureWarning:xarray.tests.test_variable",
"default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning",
"default:Duplicate dimension names present:UserWarning:xarray.namedarray.core",
# Zarr 2 V3 implementation
"ignore:Zarr-Python is not in alignment with the final V3 specification",
# TODO: this is raised for vlen-utf8, consolidated metadata, U1 dtype
"ignore:is currently not part .* the Zarr version 3 specification.",
# TODO: remove once we know how to deal with a changed signature in protocols
Expand Down
7 changes: 7 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,9 @@ def roundtrip(
with self.open(store_target, **open_kwargs) as ds:
yield ds

def test_roundtrip_bytes_with_fill_value(self):
pytest.xfail("Broken by Zarr 3.0.7")

@pytest.mark.parametrize("consolidated", [False, True, None])
def test_roundtrip_consolidated(self, consolidated) -> None:
expected = create_test_data()
Expand Down Expand Up @@ -3548,6 +3551,10 @@ def test_append(self) -> None:
)

@requires_dask
@pytest.mark.skipif(
sys.version_info.major == 3 and sys.version_info.minor < 11,
reason="zarr too old",
)
def test_region_write(self) -> None:
ds = Dataset({"foo": ("x", [1, 2, 3])}, coords={"x": [1, 2, 3]}).chunk()
with self.create_zarr_target() as store:
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3608,8 +3608,8 @@ def test_to_and_from_dict(
return_data = array.to_numpy()
coords_data = np.array(["a", "b"])
if data == "list" or data is True:
return_data = return_data.tolist() # type:ignore[assignment]
coords_data = coords_data.tolist() # type:ignore[assignment]
return_data = return_data.tolist()
coords_data = coords_data.tolist()

expected: dict[str, Any] = {
"name": "foo",
Expand Down
8 changes: 8 additions & 0 deletions xarray/tests/test_duck_array_wrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
},
}

try:
import jax

# enable double-precision
jax.config.update("jax_enable_x64", True)
except ImportError:
pass


class _BaseTest:
def setup_for_test(self, request, namespace):
Expand Down
3 changes: 2 additions & 1 deletion xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2444,7 +2444,8 @@ def test_to_index(self):

def test_to_index_multiindex_level(self):
midx = pd.MultiIndex.from_product([["a", "b"], [1, 2]], names=("one", "two"))
ds = Dataset(coords={"x": midx})
with pytest.warns(FutureWarning):
ds = Dataset(coords={"x": midx})
assert ds.one.variable.to_index().equals(midx.get_level_values("one"))

def test_multiindex_default_level_names(self):
Expand Down
Loading