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

Method test_setitem_using_list

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

Source from the content-addressed store, hash-verified

4902 assert np.issubdtype(ds.x.dtype, dtype)
4903
4904 def test_setitem_using_list(self) -> None:
4905 # assign a list of variables
4906 var1 = Variable(["dim1"], np.random.randn(8))
4907 var2 = Variable(["dim1"], np.random.randn(8))
4908 actual = create_test_data()
4909 expected = actual.copy()
4910 expected["A"] = var1
4911 expected["B"] = var2
4912 actual[["A", "B"]] = [var1, var2]
4913 assert_identical(actual, expected)
4914 # assign a list of dataset arrays
4915 dv = 2 * expected[["A", "B"]]
4916 actual[["C", "D"]] = [d.variable for d in dv.data_vars.values()]
4917 expected[["C", "D"]] = dv
4918 assert_identical(actual, expected)
4919
4920 @pytest.mark.parametrize(
4921 "var_list, data, error_regex",

Callers

nothing calls this directly

Calls 5

VariableClass · 0.90
create_test_dataFunction · 0.90
assert_identicalFunction · 0.90
copyMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected