Skip to content

Fix tests on big-endian systems #9380

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 1 commit into from
Aug 19, 2024
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
6 changes: 3 additions & 3 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def test_roundtrip_empty_vlen_string_array(self) -> None:
if actual["a"].dtype.metadata is not None:
assert check_vlen_dtype(actual["a"].dtype) is str
else:
assert actual["a"].dtype == np.dtype("<U1")
assert actual["a"].dtype == np.dtype("=U1")

@pytest.mark.parametrize(
"decoded_fn, encoded_fn",
Expand Down Expand Up @@ -1430,8 +1430,8 @@ def test_encoding_kwarg_vlen_string(
expected = Dataset({"x": expected_string})
kwargs = dict(encoding={"x": {"dtype": str}})
with self.roundtrip(original, save_kwargs=kwargs) as actual:
assert actual["x"].encoding["dtype"] == "<U3"
assert actual["x"].dtype == "<U3"
assert actual["x"].encoding["dtype"] == "=U3"
assert actual["x"].dtype == "=U3"
assert_identical(actual, expected)

@pytest.mark.parametrize("fill_value", ["XXX", "", "bár"])
Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_coding_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def test_roundtrip_datetime64_nanosecond_precision(
encoding = {}

var = Variable(["time"], times, encoding=encoding)
assert var.dtype == np.dtype("<M8[ns]")
assert var.dtype == np.dtype("=M8[ns]")

encoded_var = conventions.encode_cf_variable(var)
assert (
Expand All @@ -1264,7 +1264,7 @@ def test_roundtrip_datetime64_nanosecond_precision(
assert encoded_var.data.dtype == dtype

decoded_var = conventions.decode_cf_variable("foo", encoded_var)
assert decoded_var.dtype == np.dtype("<M8[ns]")
assert decoded_var.dtype == np.dtype("=M8[ns]")
assert (
decoded_var.encoding["units"]
== f"{_numpy_to_netcdf_timeunit(timeunit)} since 1970-01-01 00:00:00"
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ def test_map_blocks_roundtrip_string_index():
ds = xr.Dataset(
{"data": (["label"], [1, 2, 3])}, coords={"label": ["foo", "bar", "baz"]}
).chunk(label=1)
assert ds.label.dtype == np.dtype("<U3")
assert ds.label.dtype == np.dtype("=U3")

mapped = ds.map_blocks(lambda x: x, template=ds)
assert mapped.label.dtype == ds.label.dtype
Expand Down
Loading