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

Method test_to_dataarray

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

Source from the content-addressed store, hash-verified

5263 assert_identical(data, selected)
5264
5265 def test_to_dataarray(self) -> None:
5266 ds = Dataset(
5267 {"a": 1, "b": ("x", [1, 2, 3])},
5268 coords={"c": 42},
5269 attrs={"Conventions": "None"},
5270 )
5271 data = [[1, 1, 1], [1, 2, 3]]
5272 coords = {"c": 42, "variable": ["a", "b"]}
5273 dims = ("variable", "x")
5274 expected = DataArray(data, coords, dims, attrs=ds.attrs)
5275 actual = ds.to_dataarray()
5276 assert_identical(expected, actual)
5277
5278 actual = ds.to_dataarray("abc", name="foo")
5279 expected = expected.rename({"variable": "abc"}).rename("foo")
5280 assert_identical(expected, actual)
5281
5282 def test_to_and_from_dataframe(self) -> None:
5283 x = np.random.randn(10)

Callers

nothing calls this directly

Calls 6

to_dataarrayMethod · 0.95
renameMethod · 0.95
DatasetClass · 0.90
DataArrayClass · 0.90
assert_identicalFunction · 0.90
renameMethod · 0.45

Tested by

no test coverage detected