Skip to content

Commit

Permalink
[BACKPORT] Fix misuse of name parameter in DataFrame align (#2469) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wjsi authored Sep 21, 2021
1 parent a55b150 commit cfeef0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mars/dataframe/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def build_map_chunk_kw(self, inputs, **kw):
if kw.get('dtype', None) is None and getattr(inputs[0], 'dtype', None) is not None:
kw['dtype'] = inputs[0].dtype
if kw.get('name', None) is None and getattr(inputs[0], 'name', None) is not None:
kw['name'] = inputs[0].dtype
kw['name'] = inputs[0].name
return kw

def build_reduce_chunk_kw(self, inputs, index, **kw):
Expand Down Expand Up @@ -192,7 +192,7 @@ def build_reduce_chunk_kw(self, inputs, index, **kw):
if kw.get('dtype', None) is None and getattr(inputs[0].inputs[0], 'dtype', None) is not None:
kw['dtype'] = inputs[0].inputs[0].dtype
if kw.get('name', None) is None and getattr(inputs[0].inputs[0], 'name', None) is not None:
kw['name'] = inputs[0].inputs[0].dtype
kw['name'] = inputs[0].inputs[0].name
return kw

@classmethod
Expand Down
9 changes: 9 additions & 0 deletions mars/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,12 @@ def print_fun():
rm.execute()
logs = str(rm.fetch_log()).strip()
assert logs == 'inner\nafter'


def test_align_series(setup):
t = np.random.rand(10, 3)
pdf = pd.DataFrame(t)
df = md.DataFrame(pdf, chunk_size=(5, 3))
r = df[0] != df.sort_index()[0].shift(-1)
expected = pdf[0] != pdf.sort_index()[0].shift(-1)
pd.testing.assert_series_equal(r.execute().fetch(), expected)

0 comments on commit cfeef0c

Please sign in to comment.