Skip to content

Commit 9b6e067

Browse files
committed
avoid divide by zero for showing empty tensors
1 parent d82de02 commit 9b6e067

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/tensors/blockiterator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function show_blocks(io, mime::MIME"text/plain", iter; maytruncate::Bool = true)
5050
numlinesleft, numcols = get(io, :displaysize, displaysize(io))::Tuple{Int, Int}
5151
numlinesleft -= 2 # lines of headers have already been subtracted, but not the 2 spare lines for old and new prompts
5252
minlinesperblock = 7 # aim to have at least this many lines per printed block (= 5 lines for the actual matrix)
53-
minnumberofblocks = min(3, length(iter)) # aim to show at least this many blocks
53+
minnumberofblocks = clamp(length(iter), 1, 3) # aim to show at least this many blocks
5454
truncateblocks = sum(cb -> min(size(cb[2], 1) + 2, minlinesperblock), iter; init = 0) > numlinesleft
5555
maxnumlinesperblock = max(div(numlinesleft - 2 * truncateblocks, minnumberofblocks), minlinesperblock)
5656
# aim to show at least minnumberofblocks, but not if this means that there would be less than minlinesperblock

0 commit comments

Comments
 (0)