Skip to content

Commit

Permalink
Simplify empty cell
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Aug 26, 2023
1 parent be73772 commit 07ae10b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions matrepr/list_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ def __init__(self, max_rows, max_cols, num_after_dots, floatfmt, **_):
self.max_cols = max_cols
self.num_after_dots = num_after_dots
self.floatfmt = floatfmt
self.empty_cell = ""
self.replace_newline_char = " "
self.use_fixed_width_dots = True

def pprint(self, obj):
if obj is None:
return ""
return self.empty_cell

if isinstance(obj, (int, float)):
formatted = self.floatfmt(obj)
Expand Down Expand Up @@ -85,7 +86,7 @@ def pprint(self, obj):

return obj

def _write_matrix(self, mat: MatrixAdapterRow, empty_cell="", is_vector=False):
def _write_matrix(self, mat: MatrixAdapterRow, is_vector=False):
if isinstance(mat, Truncated2DMatrix):
mat.apply_dots(unicode_dots)

Expand All @@ -95,10 +96,9 @@ def _write_matrix(self, mat: MatrixAdapterRow, empty_cell="", is_vector=False):

# values
for row_idx in range(nrows):
row = [empty_cell] * ncols
row = [self.empty_cell] * ncols
for col_idx, cell in mat.get_row(row_idx, col_range=(0, ncols)):
if cell is not None:
row[col_idx] = self.pprint(cell)
row[col_idx] = self.pprint(cell)

ret.append(row)
return ret[0] if is_vector else ret
Expand Down

0 comments on commit 07ae10b

Please sign in to comment.