Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multidimensional variable with same name as dim when constructing dataset via coords #8886

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
regression test
TomNicholas committed Mar 28, 2024
commit aae007736a68462299e36e66481ba589b1fbe758
10 changes: 9 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

@@ -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


@@ -174,3 +175,10 @@ def test_align(self) -> None:
left2, right2 = align(left, right, join="override")
assert_identical(left2, left)
assert_identical(left2, right2)

def test_dataset_from_coords_with_multidim_var_same_name(self):
# regression test for GH #8883
var = Variable(data=np.arange(6).reshape(2, 3), dims=["x", "y"])
coords = Coordinates(coords={"x": var}, indexes={})
ds = Dataset(coords=coords)
assert ds.coords["x"].dims == ("x", "y")