Skip to content

Commit 809f27c

Browse files
mcabbottMichael Abbott
andauthored
move printing of [:, :, 1, 2] = to label_nd_slices (#38341)
Co-authored-by: Michael Abbott <me@escbook>
1 parent af4c97c commit 809f27c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

base/arrayshow.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ function show_nd(io::IO, a::AbstractArray, print_matrix::Function, label_slices:
286286
@goto skip
287287
end
288288
end
289-
#println(io, idxs)
290289
print(io, "...\n\n")
291290
@goto skip
292291
end
@@ -297,9 +296,7 @@ function show_nd(io::IO, a::AbstractArray, print_matrix::Function, label_slices:
297296
end
298297
end
299298
if label_slices
300-
print(io, "[:, :, ")
301-
for i = 1:(nd-1); print(io, "$(idxs[i]), "); end
302-
println(io, idxs[end], "] =")
299+
_show_nd_label(io, a, idxs)
303300
end
304301
slice = view(a, axes(a,1), axes(a,2), idxs...)
305302
print_matrix(io, slice)
@@ -308,6 +305,14 @@ function show_nd(io::IO, a::AbstractArray, print_matrix::Function, label_slices:
308305
end
309306
end
310307

308+
function _show_nd_label(io::IO, a::AbstractArray, idxs)
309+
print(io, "[:, :, ")
310+
for i = 1:length(idxs)-1
311+
print(io, idxs[i], ", ")
312+
end
313+
println(io, idxs[end], "] =")
314+
end
315+
311316
# print_array: main helper functions for show(io, text/plain, array)
312317
# typeinfo agnostic
313318
# Note that this is for showing the content inside the array, and for `MIME"text/plain".

0 commit comments

Comments
 (0)