diff --git a/xray/core/merge.py b/xray/core/merge.py index c1830127fbc..5f6c7ede787 100644 --- a/xray/core/merge.py +++ b/xray/core/merge.py @@ -151,7 +151,7 @@ def _reindex_variables_against(variables, indexes, copy=False): """Reindex all DataArrays in the provided dict, leaving other values alone. """ alignable = [k for k, v in variables.items() if hasattr(v, 'indexes')] - aligned = [variables[a].reindex(copy=copy, indexes=indexes) + aligned = [variables[a].reindex(copy=copy, **indexes) for a in alignable] new_variables = OrderedDict(variables) new_variables.update(zip(alignable, aligned)) diff --git a/xray/test/test_dataarray.py b/xray/test/test_dataarray.py index 1a1b5e883e0..2e1ae6381e8 100644 --- a/xray/test/test_dataarray.py +++ b/xray/test/test_dataarray.py @@ -603,6 +603,15 @@ def test_assign_coords(self): expected.coords['d'] = ('x', [1.5, 1.5, 3.5, 3.5]) self.assertDataArrayIdentical(actual, expected) + def test_coords_alignment(self): + lhs = DataArray([1, 2, 3], [('x', [0, 1, 2])]) + rhs = DataArray([2, 3, 4], [('x', [1, 2, 3])]) + lhs.coords['rhs'] = rhs + + expected = DataArray([1, 2, 3], coords={'rhs': ('x', [np.nan, 2, 3])}, + dims='x') + self.assertDataArrayIdentical(lhs, expected) + def test_reindex(self): foo = self.dv bar = self.dv[:2, :2]