Skip to content

Upstream xarray causing build to fail with "ValueError: unmatched dimensions for multi-index variables" #850

Description

@tomwhite

From https://github.com/pystatgen/sgkit/runs/6213029601?check_suite_focus=true:

=================================== FAILURES ===================================
________________________ test_variables_in_multi_index _________________________

dummy_ds = <xarray.Dataset>
Dimensions:  (d1: 3, bar: 3)
Coordinates:
  * bar      (bar) int64 1 2 3
Dimensions without coordinates: d1
Data variables:
    foo      (d1) int64 1 2 3

    def test_variables_in_multi_index(dummy_ds: xr.Dataset) -> None:
        # create a multi index
>       ds = dummy_ds.set_index({"ind": ("foo", "bar")})

sgkit/tests/test_variables.py:98: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/xarray/core/dataset.py:3766: in set_index
    idx, idx_vars = PandasMultiIndex.from_variables_maybe_expand(
/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/xarray/core/indexes.py:660: in from_variables_maybe_expand
    _check_dim_compat({**current_variables, **variables})
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

variables = {'bar': <xarray.IndexVariable 'bar' (bar: 3)>
array([1, 2, 3]), 'foo': <xarray.Variable (d1: 3)>
array([1, 2, 3])}
all_dims = 'equal'

    def _check_dim_compat(variables: Mapping[Any, Variable], all_dims: str = "equal"):
        """Check that all multi-index variable candidates are 1-dimensional and
        either share the same (single) dimension or each have a different dimension.
    
        """
        if any([var.ndim != 1 for var in variables.values()]):
            raise ValueError("PandasMultiIndex only accepts 1-dimensional variables")
    
        dims = {var.dims for var in variables.values()}
    
        if all_dims == "equal" and len(dims) > 1:
>           raise ValueError(
                "unmatched dimensions for multi-index variables "
                + ", ".join([f"{k!r} {v.dims}" for k, v in variables.items()])
            )
E           ValueError: unmatched dimensions for multi-index variables 'foo' ('d1',), 'bar' ('bar',)

/opt/hostedtoolcache/Python/3.9.12/x64/lib/python3.9/site-packages/xarray/core/indexes.py:491: ValueError
=========================== short test summary info ============================
FAILED sgkit/tests/test_variables.py::test_variables_in_multi_index - ValueEr...
= 1 failed, 826 passed, 32 skipped, 2 xfailed, 1 xpassed in 243.48s (0:04:03) ==

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamUsed when our build breaks due to upstream changes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions