(self)
| 2276 | assert_identical(original2.broadcast_like(original1), expected2) |
| 2277 | |
| 2278 | def test_to_pandas(self) -> None: |
| 2279 | # 0D -> series |
| 2280 | actual = Dataset({"a": 1, "b": 2}).to_pandas() |
| 2281 | expected = pd.Series([1, 2], ["a", "b"]) |
| 2282 | assert_array_equal(actual, expected) |
| 2283 | |
| 2284 | # 1D -> dataframe |
| 2285 | x = np.random.randn(10) |
| 2286 | y = np.random.randn(10) |
| 2287 | t = list("abcdefghij") |
| 2288 | ds = Dataset({"a": ("t", x), "b": ("t", y), "t": ("t", t)}) |
| 2289 | actual_df = ds.to_pandas() |
| 2290 | expected_df = ds.to_dataframe() |
| 2291 | assert expected_df.equals(actual_df), (expected_df, actual_df) |
| 2292 | |
| 2293 | # 2D -> error |
| 2294 | x2d = np.random.randn(10, 10) |
| 2295 | y2d = np.random.randn(10, 10) |
| 2296 | with pytest.raises(ValueError, match=r"cannot convert Datasets"): |
| 2297 | Dataset({"a": (["t", "r"], x2d), "b": (["t", "r"], y2d)}).to_pandas() |
| 2298 | |
| 2299 | def test_reindex_like(self) -> None: |
| 2300 | data = create_test_data() |
nothing calls this directly
no test coverage detected