Skip to content

Commit 9c86451

Browse files
committed
Fix a bug in alignment when assigning to DataArray.coords
I noticed that the doc build was broken. This was introduced by GH648, so it hasn't appeared in a released version yet.
1 parent e1097cf commit 9c86451

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

xray/core/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def _reindex_variables_against(variables, indexes, copy=False):
151151
"""Reindex all DataArrays in the provided dict, leaving other values alone.
152152
"""
153153
alignable = [k for k, v in variables.items() if hasattr(v, 'indexes')]
154-
aligned = [variables[a].reindex(copy=copy, indexes=indexes)
154+
aligned = [variables[a].reindex(copy=copy, **indexes)
155155
for a in alignable]
156156
new_variables = OrderedDict(variables)
157157
new_variables.update(zip(alignable, aligned))

xray/test/test_dataarray.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,15 @@ def test_assign_coords(self):
603603
expected.coords['d'] = ('x', [1.5, 1.5, 3.5, 3.5])
604604
self.assertDataArrayIdentical(actual, expected)
605605

606+
def test_coords_alignment(self):
607+
lhs = DataArray([1, 2, 3], [('x', [0, 1, 2])])
608+
rhs = DataArray([2, 3, 4], [('x', [1, 2, 3])])
609+
lhs.coords['rhs'] = rhs
610+
611+
expected = DataArray([1, 2, 3], coords={'rhs': ('x', [np.nan, 2, 3])},
612+
dims='x')
613+
self.assertDataArrayIdentical(lhs, expected)
614+
606615
def test_reindex(self):
607616
foo = self.dv
608617
bar = self.dv[:2, :2]

0 commit comments

Comments
 (0)