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
Currently concatenation will automatically create indexes for any dimension coordinates in the output, even if there were no indexes on the input.
What did you expect to happen?
Indexes not to be created for variables which did not already have them.
Minimal Complete Verifiable Example
# TODO once passing indexes={} directly to DataArray constructor is allowed then no need to create coords object separately firstcoords=Coordinates(
{"x": np.array([1, 2, 3])}, indexes={}
)
arrays= [
DataArray(
np.zeros((3, 3)),
dims=["x", "y"],
coords=coords,
)
for_inrange(2)
]
combined=concat(arrays, dim="x")
assertcombined.shape== (6, 3)
assertcombined.dims== ("x", "y")
# should not have auto-created any indexesassertcombined.indexes== {} # this failscombined=concat(arrays, dim="z")
assertcombined.shape== (2, 3, 3)
assertcombined.dims== ("z", "x", "y")
# should not have auto-created any indexesassertcombined.indexes== {} # this also fails
MVCE confirmation
Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
Complete example — the example is self-contained, including all data and the text of any traceback.
Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
New issue — a search of GitHub Issues suggests this is not a duplicate.
Recent environment — the issue occurs with the latest version of xarray and its dependencies.
The culprit is the call to core.indexes.create_default_index_implicit inside merge.py. If I comment out this call my concat test passes, but basic tests in test_merge.py start failing.
I would like know to how to avoid the internal call to create_default_index_implicit. I tried passing compat='override' but that made no difference, so I think we would have to change merge.collect_variables_and_indexes somehow.
Conceptually, I would have thought we should be examining what indexes exist on the objects to be concatenated, and not creating new indexes for any variable that doesn't already have one. Presumably we should therefore be making use of the indexes argument to merge.collect_variables_and_indexes, but currently that just seems to be empty.
Environment
I've been experimenting running this test on a branch that includes both #8711 and #8714, but actually this example will fail in the same way on main.
The text was updated successfully, but these errors were encountered:
What happened?
Currently concatenation will automatically create indexes for any dimension coordinates in the output, even if there were no indexes on the input.
What did you expect to happen?
Indexes not to be created for variables which did not already have them.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
The culprit is the call to
core.indexes.create_default_index_implicit
insidemerge.py
. If I comment out this call my concat test passes, but basic tests intest_merge.py
start failing.I would like know to how to avoid the internal call to
create_default_index_implicit
. I tried passingcompat='override'
but that made no difference, so I think we would have to changemerge.collect_variables_and_indexes
somehow.Conceptually, I would have thought we should be examining what indexes exist on the objects to be concatenated, and not creating new indexes for any variable that doesn't already have one. Presumably we should therefore be making use of the
indexes
argument tomerge.collect_variables_and_indexes
, but currently that just seems to be empty.Environment
I've been experimenting running this test on a branch that includes both #8711 and #8714, but actually this example will fail in the same way on
main
.The text was updated successfully, but these errors were encountered: