Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danking committed Mar 22, 2019
1 parent 015d7e8 commit fe0e3ba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hail/python/hail/matrixtable.py
Expand Up @@ -2500,19 +2500,20 @@ def show(self,
"""

def estimate_size(struct_expression):
return sum(len(str(x.dtype)) + 3
for x in struct_expression.flatten().values())
return sum(max(len(f), len(str(x.dtype))) + 3
for f, x in struct_expression.flatten().items())

if n_cols is None:
characters_per_field = 10
import shutil
(characters, _) = shutil.get_terminal_size((80, 10))
characters -= 6 # borders
key_characters = estimate_size(self.row_key)
characters -= key_characters
if include_row_fields:
characters -= estimate_size(self.row_value)
characters = max(characters, 0)
n_cols = max(5, characters // estimate_size(self.entry))
n_cols = characters // (estimate_size(self.entry) + 4) # 4 for the column index

t = self.localize_entries('entries', 'cols')
t = t.key_by()
Expand Down

0 comments on commit fe0e3ba

Please sign in to comment.