Skip to content

Commit

Permalink
Fix __repr__ output with display.max_rows is None (#8547)
Browse files Browse the repository at this point in the history
Fixes: #6978 

This PR fixes `__repr__` output when `display.max_rows` is `None`, when it is `None` the output must have all the rows of series printed. This is already being handled as part of dataframe.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Michael Wang (https://github.com/isVoid)

URL: #8547
  • Loading branch information
galipremsagar authored Jun 18, 2021
1 parent d183d50 commit 1de662f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ def __repr__(self):
if get_option("display.max_rows") == 0
else get_option("display.max_rows")
)
if len(self) > max_rows and max_rows != 0:
if max_rows not in (0, None) and len(self) > max_rows:
top = self.head(int(max_rows / 2 + 1))
bottom = self.tail(int(max_rows / 2 + 1))
preprocess = cudf.concat([top, bottom])
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def __repr__(self):
):
min_rows = (
height
if get_option("display.max_rows") == 0
if get_option("display.min_rows") == 0
else get_option("display.min_rows")
)
show_dimensions = get_option("display.show_dimensions")
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/tests/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def test_null_dataframe(ncols):


@pytest.mark.parametrize("dtype", repr_categories)
@pytest.mark.parametrize("nrows", [0, 1, 2, 9, 10, 11, 19, 20, 21])
@pytest.mark.parametrize("nrows", [None, 0, 1, 2, 9, 10, 11, 19, 20, 21])
def test_full_series(nrows, dtype):
size = 20
ps = pd.Series(np.random.randint(0, 100, size)).astype(dtype)
sr = cudf.from_pandas(ps)
pd.options.display.max_rows = int(nrows)
pd.options.display.max_rows = nrows
assert ps.__repr__() == sr.__repr__()
pd.reset_option("display.max_rows")

Expand Down

0 comments on commit 1de662f

Please sign in to comment.