Skip to content

Commit e4b178b

Browse files
committed
Add netcdf writing test
1 parent 5b02247 commit e4b178b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/test_xarray_io.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,25 @@ def test_xarray_to_binary_flatten_blocks(
264264
)
265265

266266

267+
def create_and_write_netcdf(file_path, data: xr.DataArray):
268+
data.to_netcdf(file_path, format="NETCDF4", engine="netcdf4")
269+
270+
271+
@pytest.mark.parametrize("max_size,chunks", test_combinations)
272+
@pytest.mark.timing
273+
def test_xarray_to_binary_netcdf(tmp_path, max_size, chunks, time_file):
274+
data = xr.DataArray(da.arange(0, max_size, 1), dims="x")
275+
data = data.chunk(chunks)
276+
file_path = tmp_path / "test_xarray_to_binary_netcdf.nc"
277+
278+
profile_function(
279+
create_and_write_netcdf,
280+
(file_path, data),
281+
time_file,
282+
print_args={"max_size": max_size, "chunks": chunks},
283+
)
284+
285+
267286
@pytest.mark.parametrize("max_size,chunks", test_combinations)
268287
@pytest.mark.memory
269288
@pytest.mark.skip("Memory tests take a long time to run")

0 commit comments

Comments
 (0)