()
| 123 | |
| 124 | |
| 125 | def test_concat_compat() -> None: |
| 126 | ds1 = Dataset( |
| 127 | { |
| 128 | "has_x_y": (("y", "x"), [[1, 2]]), |
| 129 | "has_x": ("x", [1, 2]), |
| 130 | "no_x_y": ("z", [1, 2]), |
| 131 | }, |
| 132 | coords={"x": [0, 1], "y": [0], "z": [-1, -2]}, |
| 133 | ) |
| 134 | ds2 = Dataset( |
| 135 | { |
| 136 | "has_x_y": (("y", "x"), [[3, 4]]), |
| 137 | "has_x": ("x", [1, 2]), |
| 138 | "no_x_y": (("q", "z"), [[1, 2]]), |
| 139 | }, |
| 140 | coords={"x": [0, 1], "y": [1], "z": [-1, -2], "q": [0]}, |
| 141 | ) |
| 142 | |
| 143 | result = concat([ds1, ds2], dim="y", data_vars="minimal", compat="broadcast_equals") |
| 144 | assert_equal(ds2.no_x_y, result.no_x_y.transpose()) |
| 145 | |
| 146 | for var in ["has_x", "no_x_y"]: |
| 147 | assert "y" not in result[var].dims and "y" not in result[var].coords |
| 148 | with pytest.raises(ValueError, match=r"'q' not present in all datasets"): |
| 149 | concat([ds1, ds2], dim="q", data_vars="all", join="outer") |
| 150 | with pytest.raises(ValueError, match=r"'q' not present in all datasets"): |
| 151 | concat([ds2, ds1], dim="q", data_vars="all", join="outer") |
| 152 | |
| 153 | |
| 154 | def test_concat_missing_var() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…