Test that FillValueCoder round-trips complex fill values.
(dtype)
| 7244 | @requires_zarr |
| 7245 | @pytest.mark.parametrize("dtype", [complex, np.complex64, np.complex128]) |
| 7246 | def test_fill_value_coder_complex(dtype) -> None: |
| 7247 | """Test that FillValueCoder round-trips complex fill values.""" |
| 7248 | from xarray.backends.zarr import FillValueCoder |
| 7249 | |
| 7250 | for value in [dtype(1 + 2j), dtype(-3.5 + 4.5j), dtype(complex("nan+nanj"))]: |
| 7251 | encoded = FillValueCoder.encode(value, np.dtype(dtype)) |
| 7252 | decoded = FillValueCoder.decode(encoded, np.dtype(dtype)) |
| 7253 | np.testing.assert_equal(np.array(decoded, dtype=dtype), np.array(value)) |
| 7254 | |
| 7255 | |
| 7256 | @requires_zarr |