Skip to content

Commit

Permalink
[Python] Detect width of terminal for SolutionArray.info
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Apr 11, 2023
1 parent 756f595 commit 38b51fd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion interfaces/cython/cantera/solutionbase.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
cimport numpy as np
import numpy as np
from pathlib import PurePath
from os import get_terminal_size
import warnings

from .thermo cimport *
Expand Down Expand Up @@ -538,7 +539,7 @@ cdef class SolutionArrayBase:
cxx_shape.push_back(dim)
self.base.setApiShape(cxx_shape)

def info(self, keys=None, rows=10, width=80):
def info(self, keys=None, rows=10, width=None):
"""
Print a concise summary of a `SolutionArray`.
Expand All @@ -560,6 +561,12 @@ cdef class SolutionArrayBase:
for key in self.component_names:
if key not in names or key in keep:
cxx_keys.push_back(stringify(key))
if width is None:
try:
width = get_terminal_size().columns
except:
width = 100

return pystr(self.base.info(cxx_keys, rows, width))

@property
Expand Down

0 comments on commit 38b51fd

Please sign in to comment.