Skip to content

Commit a11c239

Browse files
authored
fix: typestr respects now limit_cols for .show and _repr_mimebundle_ (#3712)
1 parent a61846b commit a11c239

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/awkward/highlevel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ def show(
14581458
# it's always the second row (after the array)
14591459
type_line = rows.pop(0)
14601460
out_io.write(type_line)
1461+
out_io.write("\n")
14611462

14621463
# the rest of the rows we sort by the length of their '<prefix>:'
14631464
# but we sort it from shortest to longest contrary to _repr_mimebundle_
@@ -2408,6 +2409,7 @@ def show(
24082409
# it's always the second row (after the array)
24092410
type_line = rows.pop(0)
24102411
out_io.write(type_line)
2412+
out_io.write("\n")
24112413

24122414
# the rest of the rows we sort by the length of their '<prefix>:'
24132415
# but we sort it from shortest to longest contrary to _repr_mimebundle_

src/awkward/prettyprint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ def highlevel_array_show_rows(
487487
array.type.show(stream=typeio)
488488
type_line = "type: "
489489
type_line += typeio.getvalue().removesuffix("\n")
490+
# crop type line if too long
491+
if len(type_line) > limit_cols:
492+
type_line = type_line[: limit_cols - 3] + "..."
490493
rows.append(type_line)
491494

492495
# other info
@@ -495,6 +498,9 @@ def highlevel_array_show_rows(
495498
named_axis_line += _prettify_named_axes(
496499
array.named_axis, delimiter=", ", maxlen=None
497500
)
501+
# crop named axis line if too long
502+
if len(named_axis_line) > limit_cols:
503+
named_axis_line = named_axis_line[: limit_cols - 3] + "..."
498504
rows.append(named_axis_line)
499505
if nbytes:
500506
if array.nbytes is unknown_length:

0 commit comments

Comments
 (0)