MCPcopy Index your code
hub / github.com/pydata/xarray / test_open_mfdataset_list_attr

Function test_open_mfdataset_list_attr

xarray/tests/test_backends.py:5568–5587  ·  view source on GitHub ↗

Case when an attribute of type list differs across the multiple files

()

Source from the content-addressed store, hash-verified

5566@requires_netCDF4
5567@requires_dask
5568def test_open_mfdataset_list_attr() -> None:
5569 """
5570 Case when an attribute of type list differs across the multiple files
5571 """
5572 with create_tmp_files(2) as nfiles:
5573 for i in range(2):
5574 with nc4.Dataset(nfiles[i], "w") as f:
5575 f.createDimension("x", 3)
5576 vlvar = f.createVariable("test_var", np.int32, ("x"))
5577 # here create an attribute as a list
5578 vlvar.test_attr = [f"string a {i}", f"string b {i}"]
5579 vlvar[:] = np.arange(3)
5580
5581 with open_dataset(nfiles[0]) as ds1:
5582 with open_dataset(nfiles[1]) as ds2:
5583 original = xr.concat([ds1, ds2], dim="x")
5584 with xr.open_mfdataset(
5585 [nfiles[0], nfiles[1]], combine="nested", concat_dim="x"
5586 ) as actual:
5587 assert_identical(actual, original)
5588
5589
5590@requires_scipy_or_netCDF4

Callers

nothing calls this directly

Calls 5

open_datasetFunction · 0.90
assert_identicalFunction · 0.90
create_tmp_filesFunction · 0.85
arangeMethod · 0.80
concatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…