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

Method test_broadcast_like

xarray/tests/test_dataarray.py:1805–1828  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1803 del self.mda.coords["level_1"]
1804
1805 def test_broadcast_like(self) -> None:
1806 arr1 = DataArray(
1807 np.ones((2, 3)),
1808 dims=["x", "y"],
1809 coords={"x": ["a", "b"], "y": ["a", "b", "c"]},
1810 )
1811 arr2 = DataArray(
1812 np.ones((3, 2)),
1813 dims=["x", "y"],
1814 coords={"x": ["a", "b", "c"], "y": ["a", "b"]},
1815 )
1816 orig1, orig2 = broadcast(arr1, arr2)
1817 new1 = arr1.broadcast_like(arr2)
1818 new2 = arr2.broadcast_like(arr1)
1819
1820 assert_identical(orig1, new1)
1821 assert_identical(orig2, new2)
1822
1823 orig3 = DataArray(np.random.randn(5), [("x", range(5))])
1824 orig4 = DataArray(np.random.randn(6), [("y", range(6))])
1825 new3, new4 = broadcast(orig3, orig4)
1826
1827 assert_identical(orig3.broadcast_like(orig4), new3.transpose("y", "x"))
1828 assert_identical(orig4.broadcast_like(orig3), new4)
1829
1830 def test_reindex_like(self) -> None:
1831 foo = DataArray(np.random.randn(5, 6), [("x", range(5)), ("y", range(6))])

Callers

nothing calls this directly

Calls 5

broadcast_likeMethod · 0.95
DataArrayClass · 0.90
broadcastFunction · 0.90
assert_identicalFunction · 0.90
transposeMethod · 0.45

Tested by

no test coverage detected