Skip to content

Commit

Permalink
Update repr when frame has no rows or columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Oct 18, 2023
1 parent 10c81ef commit e251940
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,20 @@ def _validate(self):
self._number_of_rows = 0

def __repr__(self) -> str:
if self.row_names is None:
if self.dims[0] == 0:
return f"Empty BiocFrame with no rows & {self.dims[1]} column{'s' if self.dims[1] != 1 else ''}."

if self.dims[1] == 0:
return f"Empty BiocFrame with {self.dims[0]} row{'s' if self.dims[0] != 1 else ''} & no columns."

from io import StringIO

from rich.console import Console
from rich.table import Table

table = Table(
title=f"BiocFrame with {self.dims[0]} rows & {self.dims[1]} columns",
title=f"BiocFrame with {self.dims[0]} row{'s' if self.dims[0] != 1 else ''} & {self.dims[1]} column{'s' if self.dims[1] != 1 else ''}",
show_header=True,
)
if self.row_names is not None:
Expand Down

0 comments on commit e251940

Please sign in to comment.