Skip to content

Commit

Permalink
The test_extract_zarr_variable_encoding does not need to use the regi…
Browse files Browse the repository at this point in the history
…on parameter
  • Loading branch information
josephnowak committed Sep 20, 2024
1 parent a2a786b commit a30b1e0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -5496,26 +5496,24 @@ def test_encode_zarr_attr_value() -> None:

@requires_zarr
def test_extract_zarr_variable_encoding() -> None:
# The region is not useful in these cases, but I still think that it must be mandatory
# because the validation of the chunks is in the same function
var = xr.Variable("x", [1, 2])
actual = backends.zarr.extract_zarr_variable_encoding(var, region=tuple())
actual = backends.zarr.extract_zarr_variable_encoding(var)
assert "chunks" in actual
assert actual["chunks"] is None

var = xr.Variable("x", [1, 2], encoding={"chunks": (1,)})
actual = backends.zarr.extract_zarr_variable_encoding(var, region=tuple())
actual = backends.zarr.extract_zarr_variable_encoding(var)
assert actual["chunks"] == (1,)

# does not raise on invalid
var = xr.Variable("x", [1, 2], encoding={"foo": (1,)})
actual = backends.zarr.extract_zarr_variable_encoding(var, region=tuple())
actual = backends.zarr.extract_zarr_variable_encoding(var)

# raises on invalid
var = xr.Variable("x", [1, 2], encoding={"foo": (1,)})
with pytest.raises(ValueError, match=r"unexpected encoding parameters"):
actual = backends.zarr.extract_zarr_variable_encoding(
var, raise_on_invalid=True, region=tuple()
var, raise_on_invalid=True
)


Expand Down

0 comments on commit a30b1e0

Please sign in to comment.