MCPcopy
hub / github.com/pydata/xarray / test_update_auto_align

Method test_update_auto_align

xarray/tests/test_dataset.py:4478–4497  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4476 data.update({"level_1": range(4)})
4477
4478 def test_update_auto_align(self) -> None:
4479 ds = Dataset({"x": ("t", [3, 4])}, {"t": [0, 1]})
4480
4481 expected1 = Dataset(
4482 {"x": ("t", [3, 4]), "y": ("t", [np.nan, 5])}, {"t": [0, 1]}
4483 )
4484 actual1 = ds.copy()
4485 other1 = {"y": ("t", [5]), "t": [1]}
4486 with pytest.raises(ValueError, match=r"conflicting sizes"):
4487 actual1.update(other1)
4488 actual1.update(Dataset(other1))
4489 assert_identical(expected1, actual1)
4490
4491 actual2 = ds.copy()
4492 other2 = Dataset({"y": ("t", [5]), "t": [100]})
4493 actual2.update(other2)
4494 expected2 = Dataset(
4495 {"x": ("t", [3, 4]), "y": ("t", [np.nan] * 2)}, {"t": [0, 1]}
4496 )
4497 assert_identical(expected2, actual2)
4498
4499 def test_getitem(self) -> None:
4500 data = create_test_data()

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected