Skip to content

Commit

Permalink
BUG: Wrong dataframe id value (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou1213CN committed May 5, 2023
1 parent 626ed22 commit e9325cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 3 additions & 7 deletions python/xorbits/_mars/dataframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,13 +2296,9 @@ def __mars_tensor__(self, dtype=None, order="K"):
return self._data.__mars_tensor__(dtype=dtype, order=order)

def __getattr__(self, key):
try:
return getattr(self._data, key)
except AttributeError:
if key in self.dtypes:
return self[key]
else:
raise
if self.dtypes is not None and key in self.dtypes:
return self[key]
return getattr(self._data, key)

def __dir__(self):
result = list(super().__dir__())
Expand Down
12 changes: 12 additions & 0 deletions python/xorbits/pandas/mars_adapters/tests/test_mars_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ def test_dataframe_getattr(setup, dummy_df):
idx += 1


def test_dataframe_getattr_id(setup, dummy_df):
dummy_df["id"] = (0.0, 1.0, 2.0)
id_values = dummy_df.id
assert isinstance(id_values, DataRef)

idx = 0
for i, val in id_values.items():
assert idx == i
assert val == float(idx)
idx += 1


def test_dataframe_setattr(setup, dummy_df):
assert isinstance(dummy_df.columns, DataRef)
assert ["foo", "bar"] == list(dummy_df.dtypes.index)
Expand Down

0 comments on commit e9325cf

Please sign in to comment.