Skip to content

Commit

Permalink
add regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Mar 28, 2024
1 parent cf36559 commit beb665a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion xarray/tests/test_coordinates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import numpy as np
import pandas as pd
import pytest

Expand All @@ -8,7 +9,7 @@
from xarray.core.dataarray import DataArray
from xarray.core.dataset import Dataset
from xarray.core.indexes import PandasIndex, PandasMultiIndex
from xarray.core.variable import IndexVariable
from xarray.core.variable import IndexVariable, Variable
from xarray.tests import assert_identical, source_ndarray


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

def test_init_var_shares_name_with_dim(self) -> None:
# regression test for GH #8883
var = Variable(data=np.arange(6).reshape(2, 3), dims=["x", "y"])
with pytest.raises(ValueError):
Coordinates(coords={"x": var}, indexes={})

def test_from_pandas_multiindex(self) -> None:
midx = pd.MultiIndex.from_product([["a", "b"], [1, 2]], names=("one", "two"))
coords = Coordinates.from_pandas_multiindex(midx, "x")
Expand Down

0 comments on commit beb665a

Please sign in to comment.