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

Function create_ds

xarray/tests/test_concat.py:429–453  ·  view source on GitHub ↗
(
        var_names: list[list[str]],
        dim: bool = False,
        coord: bool = False,
        drop_idx: list[int] | None = None,
    )

Source from the content-addressed store, hash-verified

427@pytest.fixture
428def create_concat_ds() -> Callable:
429 def create_ds(
430 var_names: list[list[str]],
431 dim: bool = False,
432 coord: bool = False,
433 drop_idx: list[int] | None = None,
434 ) -> list[Dataset]:
435 out_ds = []
436 ds = Dataset()
437 ds = ds.assign_coords({"x": np.arange(2)})
438 ds = ds.assign_coords({"y": np.arange(3)})
439 ds = ds.assign_coords({"z": np.arange(4)})
440 for i, dsl in enumerate(var_names):
441 vlist = dsl.copy()
442 if drop_idx is not None:
443 vlist.pop(drop_idx[i])
444 foo_data = np.arange(48, dtype=float).reshape(2, 2, 3, 4)
445 dsi = ds.copy()
446 if coord:
447 dsi = ds.assign({"time": (["time"], [i * 2, i * 2 + 1])})
448 for k in vlist:
449 dsi = dsi.assign({k: (["time", "x", "y", "z"], foo_data.copy())})
450 if not dim:
451 dsi = dsi.isel(time=0)
452 out_ds.append(dsi)
453 return out_ds
454
455 return create_ds
456

Callers

nothing calls this directly

Calls 7

copyMethod · 0.95
assignMethod · 0.95
DatasetClass · 0.90
arangeMethod · 0.80
assign_coordsMethod · 0.45
copyMethod · 0.45
iselMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…