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

Fix alignment with join="override" when some dims are unindexed #3839

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ New Features
Bug fixes
~~~~~~~~~

- Fix alignment with ``join="override"`` when some dimensions are unindexed. (:issue:`3681`).
By `Deepak Cherian <https://github.com/dcherian>`_.
- Fix :py:meth:`Dataset.swap_dims` and :py:meth:`DataArray.swap_dims` producing
index with name reflecting the previous dimension name instead of the new one
(:issue:`3748`, :pull:`3752`). By `Joseph K Aicher
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _override_indexes(objects, all_indexes, exclude):
objects = list(objects)
for idx, obj in enumerate(objects[1:]):
new_indexes = {}
for dim in obj.dims:
for dim in obj.indexes:
if dim not in exclude:
new_indexes[dim] = all_indexes[dim][0]
objects[idx + 1] = obj._overwrite_indexes(new_indexes)
Expand Down
7 changes: 7 additions & 0 deletions xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ def test_concat_join_kwarg(self):
actual = concat([ds1, ds2], join=join, dim="x")
assert_equal(actual, expected[join])

# regression test for #3681
actual = concat([ds1.drop("x"), ds2.drop("x")], join="override", dim="y")
expected = Dataset(
{"a": (("x", "y"), np.array([0, 0], ndmin=2))}, coords={"y": [0, 0.0001]}
)
assert_identical(actual, expected)

def test_concat_promote_shape(self):
# mixed dims within variables
objs = [Dataset({}, {"x": 0}), Dataset({"x": [1]})]
Expand Down