(self)
| 539 | assert_identical(expected, actual) |
| 540 | |
| 541 | def test_constructor_auto_align(self) -> None: |
| 542 | a = DataArray([1, 2], [("x", [0, 1])]) |
| 543 | b = DataArray([3, 4], [("x", [1, 2])]) |
| 544 | |
| 545 | # verify align uses outer join |
| 546 | expected = Dataset( |
| 547 | {"a": ("x", [1, 2, np.nan]), "b": ("x", [np.nan, 3, 4])}, {"x": [0, 1, 2]} |
| 548 | ) |
| 549 | actual = Dataset({"a": a, "b": b}) |
| 550 | assert_identical(expected, actual) |
| 551 | |
| 552 | # regression test for GH346 |
| 553 | assert isinstance(actual.variables["x"], IndexVariable) |
| 554 | |
| 555 | # variable with different dimensions |
| 556 | c = ("y", [3, 4]) |
| 557 | expected2 = expected.merge({"c": c}) |
| 558 | actual = Dataset({"a": a, "b": b, "c": c}) |
| 559 | assert_identical(expected2, actual) |
| 560 | |
| 561 | # variable that is only aligned against the aligned variables |
| 562 | d = ("x", [3, 2, 1]) |
| 563 | expected3 = expected.merge({"d": d}) |
| 564 | actual = Dataset({"a": a, "b": b, "d": d}) |
| 565 | assert_identical(expected3, actual) |
| 566 | |
| 567 | e = ("x", [0, 0]) |
| 568 | with pytest.raises(ValueError, match=r"conflicting sizes"): |
| 569 | Dataset({"a": a, "b": b, "e": e}) |
| 570 | |
| 571 | def test_constructor_pandas_sequence(self) -> None: |
| 572 | ds = self.make_example_math_dataset() |
nothing calls this directly
no test coverage detected