()
| 1592 | |
| 1593 | |
| 1594 | def test_concat_multi_dim_index() -> None: |
| 1595 | ds1 = ( |
| 1596 | Dataset( |
| 1597 | {"foo": (("x", "y"), np.random.randn(2, 2))}, |
| 1598 | coords={"x": [1, 2], "y": [3, 4]}, |
| 1599 | ) |
| 1600 | .drop_indexes(["x", "y"]) |
| 1601 | .set_xindex(["x", "y"], XYIndex) |
| 1602 | ) |
| 1603 | ds2 = ( |
| 1604 | Dataset( |
| 1605 | {"foo": (("x", "y"), np.random.randn(2, 2))}, |
| 1606 | coords={"x": [1, 2], "y": [5, 6]}, |
| 1607 | ) |
| 1608 | .drop_indexes(["x", "y"]) |
| 1609 | .set_xindex(["x", "y"], XYIndex) |
| 1610 | ) |
| 1611 | |
| 1612 | expected = ( |
| 1613 | Dataset( |
| 1614 | { |
| 1615 | "foo": ( |
| 1616 | ("x", "y"), |
| 1617 | np.concatenate([ds1.foo.data, ds2.foo.data], axis=-1), |
| 1618 | ) |
| 1619 | }, |
| 1620 | coords={"x": [1, 2], "y": [3, 4, 5, 6]}, |
| 1621 | ) |
| 1622 | .drop_indexes(["x", "y"]) |
| 1623 | .set_xindex(["x", "y"], XYIndex) |
| 1624 | ) |
| 1625 | # note: missing 'override' |
| 1626 | joins: list[types.JoinOptions] = ["inner", "outer", "exact", "left", "right"] |
| 1627 | for join in joins: |
| 1628 | actual = concat([ds1, ds2], dim="y", join=join) |
| 1629 | assert_identical(actual, expected, check_default_indexes=False) |
| 1630 | |
| 1631 | with pytest.raises(AlignmentError): |
| 1632 | actual = concat([ds1, ds2], dim="x", join="exact") |
| 1633 | |
| 1634 | # TODO: fix these, or raise better error message |
| 1635 | with pytest.raises(AssertionError): |
| 1636 | joins_lr: list[types.JoinOptions] = ["left", "right"] |
| 1637 | for join in joins_lr: |
| 1638 | actual = concat([ds1, ds2], dim="x", join=join) |
| 1639 | |
| 1640 | |
| 1641 | class TestConcatDataTree: |
nothing calls this directly
no test coverage detected
searching dependent graphs…