|
35 | 35 | from xarray.core.indexes import Index, PandasIndex
|
36 | 36 | from xarray.core.pycompat import array_type, integer_types
|
37 | 37 | from xarray.core.utils import is_scalar
|
| 38 | +from xarray.testing import _assert_internal_invariants |
38 | 39 | from xarray.tests import (
|
39 | 40 | DuckArrayWrapper,
|
40 | 41 | InaccessibleArray,
|
@@ -467,13 +468,16 @@ def test_constructor(self) -> None:
|
467 | 468 |
|
468 | 469 | with pytest.raises(ValueError, match=r"conflicting sizes"):
|
469 | 470 | Dataset({"a": x1, "b": x2})
|
470 |
| - with pytest.raises(ValueError, match=r"disallows such variables"): |
471 |
| - Dataset({"a": x1, "x": z}) |
472 | 471 | with pytest.raises(TypeError, match=r"tuple of form"):
|
473 | 472 | Dataset({"x": (1, 2, 3, 4, 5, 6, 7)})
|
474 | 473 | with pytest.raises(ValueError, match=r"already exists as a scalar"):
|
475 | 474 | Dataset({"x": 0, "y": ("x", [1, 2, 3])})
|
476 | 475 |
|
| 476 | + # nD coordinate variable "x" sharing name with dimension |
| 477 | + actual = Dataset({"a": x1, "x": z}) |
| 478 | + assert "x" not in actual.xindexes |
| 479 | + _assert_internal_invariants(actual, check_default_indexes=True) |
| 480 | + |
477 | 481 | # verify handling of DataArrays
|
478 | 482 | expected = Dataset({"x": x1, "z": z})
|
479 | 483 | actual = Dataset({"z": expected["z"]})
|
|
0 commit comments