Skip to content

Commit beb665a

Browse files
committed
add regression tests
1 parent cf36559 commit beb665a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

xarray/tests/test_coordinates.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import numpy as np
34
import pandas as pd
45
import pytest
56

@@ -8,7 +9,7 @@
89
from xarray.core.dataarray import DataArray
910
from xarray.core.dataset import Dataset
1011
from xarray.core.indexes import PandasIndex, PandasMultiIndex
11-
from xarray.core.variable import IndexVariable
12+
from xarray.core.variable import IndexVariable, Variable
1213
from xarray.tests import assert_identical, source_ndarray
1314

1415

@@ -69,6 +70,12 @@ def test_init_dim_sizes_conflict(self) -> None:
6970
with pytest.raises(ValueError):
7071
Coordinates(coords={"foo": ("x", [1, 2]), "bar": ("x", [1, 2, 3, 4])})
7172

73+
def test_init_var_shares_name_with_dim(self) -> None:
74+
# regression test for GH #8883
75+
var = Variable(data=np.arange(6).reshape(2, 3), dims=["x", "y"])
76+
with pytest.raises(ValueError):
77+
Coordinates(coords={"x": var}, indexes={})
78+
7279
def test_from_pandas_multiindex(self) -> None:
7380
midx = pd.MultiIndex.from_product([["a", "b"], [1, 2]], names=("one", "two"))
7481
coords = Coordinates.from_pandas_multiindex(midx, "x")

0 commit comments

Comments
 (0)