You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resetting a MultiIndex dim coordinate preserves the MultiIndex levels as IndexVariables. We should either reset the indexes for the multiindex level variables, or warn asking the users to do so
importnumpyasnpimportxarrayasxr# ND DataArray that gets stacked along a multiindexda=xr.DataArray(np.ones((3, 3)), coords={"dim1": [1, 2, 3], "dim2": [4, 5, 6]})
da=da.stack(feature=["dim1", "dim2"])
# Extract just the stacked coordinates for saving in a datasetds=xr.Dataset(data_vars={"feature": da.feature})
xr.testing.assertions._assert_internal_invariants(ds.reset_index(["feature", "dim1", "dim2"]), check_default_indexes=False) # succeedsxr.testing.assertions._assert_internal_invariants(ds.reset_index(["feature"]), check_default_indexes=False) # fails, but no warning either
The text was updated successfully, but these errors were encountered:
Yes I think a proper fix would be to convert the variable data into a numpy array for each of the reset multi-index levels in .reset_index (#8672 (comment)).
What happened?
Resetting a MultiIndex dim coordinate preserves the MultiIndex levels as IndexVariables. We should either reset the indexes for the multiindex level variables, or warn asking the users to do so
This seems to be the root cause exposed by #8809
cc @benbovy
What did you expect to happen?
No response
Minimal Complete Verifiable Example
The text was updated successfully, but these errors were encountered: