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

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

Closed
tomwhite opened this issue Apr 28, 2022 · 1 comment · Fixed by #854
Labels
upstream Used when our build breaks due to upstream changes

Comments

@tomwhite
Copy link
Collaborator

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) ==
@tomwhite tomwhite added the upstream Used when our build breaks due to upstream changes label Apr 28, 2022
@tomwhite
Copy link
Collaborator Author

tomwhite commented May 6, 2022

This started failing after #5692 went in.

@mergify mergify bot closed this as completed in #854 May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Used when our build breaks due to upstream changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant