From 5206573fd048c5d680f2c3e67b083a65462255ec Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 23 Sep 2022 08:15:25 -0400 Subject: [PATCH 1/4] print type name in compact show --- src/host/abstractarray.jl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/host/abstractarray.jl b/src/host/abstractarray.jl index 98c0973d..0fe9f5d1 100644 --- a/src/host/abstractarray.jl +++ b/src/host/abstractarray.jl @@ -27,12 +27,21 @@ Base.print_array(io::IO, X::AnyGPUArray) = Base.print_array(io, adapt(ToArray(), X)) # show -Base._show_nonempty(io::IO, X::AnyGPUArray, prefix::String) = +function Base._show_nonempty(io::IO, X::AnyGPUArray, prefix::String) + print(io, typeof(X).name.name, "(") Base._show_nonempty(io, adapt(ToArray(), X), prefix) -Base._show_empty(io::IO, X::AnyGPUArray) = + print(io, ")") +end +function Base._show_empty(io::IO, X::AnyGPUArray) + print(io, typeof(X).name.name, "(") Base._show_empty(io, adapt(ToArray(), X)) -Base.show_vector(io::IO, v::AnyGPUArray, args...) = + print(io, ")") +end +function Base.show_vector(io::IO, v::AnyGPUArray, args...) + print(io, typeof(v).name.name, "(") Base.show_vector(io, adapt(ToArray(), v), args...) + print(io, ")") +end ## collect to CPU (discarding wrapper type) From 548a0bc2756e414ab0a3d6682e243fe256ace16f Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 23 Sep 2022 08:18:45 -0400 Subject: [PATCH 2/4] adjust tests --- test/testsuite/base.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testsuite/base.jl b/test/testsuite/base.jl index b2ac8a14..5fe3aa08 100644 --- a/test/testsuite/base.jl +++ b/test/testsuite/base.jl @@ -283,13 +283,13 @@ end # due to different definition of `Int` type # print([1]) shows as [1] on 64bit but Int64[1] on 32bit msg = showstr(A) - @test msg == "[1]" || msg == "Int64[1]" + @test occursin(msg, "[1]") || occursin(msg, "Int64[1]") msg = replstr(B) @test occursin(Regex("^2×2 $AT{Int64,\\s?2.*}:\n 1 2\n 3 4\$"), msg) msg = showstr(B) - @test msg == "[1 2; 3 4]" || msg == "Int64[1 2; 3 4]" + @test occursin(msg, "[1 2; 3 4]") || occursin(msg, "Int64[1 2; 3 4]") # the printing of Adjoint depends on global state msg = replstr(A') From b1254fad2da540c9331a15324c15ae611ebb620d Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 23 Sep 2022 09:30:23 -0400 Subject: [PATCH 3/4] contains vs occursin... --- test/testsuite/base.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testsuite/base.jl b/test/testsuite/base.jl index 5fe3aa08..3d66d8d6 100644 --- a/test/testsuite/base.jl +++ b/test/testsuite/base.jl @@ -283,13 +283,13 @@ end # due to different definition of `Int` type # print([1]) shows as [1] on 64bit but Int64[1] on 32bit msg = showstr(A) - @test occursin(msg, "[1]") || occursin(msg, "Int64[1]") + @test occursin("[1]", msg) || occursin("Int64[1]", msg) msg = replstr(B) @test occursin(Regex("^2×2 $AT{Int64,\\s?2.*}:\n 1 2\n 3 4\$"), msg) msg = showstr(B) - @test occursin(msg, "[1 2; 3 4]") || occursin(msg, "Int64[1 2; 3 4]") + @test occursin("[1 2; 3 4]", msg) || occursin("Int64[1 2; 3 4]", msg) # the printing of Adjoint depends on global state msg = replstr(A') From f82f3a9d85ef16e084cbcbbfe6cd667f22820917 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:55:28 -0400 Subject: [PATCH 4/4] Apply suggestions from code review --- test/testsuite/base.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testsuite/base.jl b/test/testsuite/base.jl index 3d66d8d6..54843ab5 100644 --- a/test/testsuite/base.jl +++ b/test/testsuite/base.jl @@ -283,13 +283,13 @@ end # due to different definition of `Int` type # print([1]) shows as [1] on 64bit but Int64[1] on 32bit msg = showstr(A) - @test occursin("[1]", msg) || occursin("Int64[1]", msg) + @test occursin("([1])", msg) || occursin("(Int64[1])", msg) msg = replstr(B) @test occursin(Regex("^2×2 $AT{Int64,\\s?2.*}:\n 1 2\n 3 4\$"), msg) msg = showstr(B) - @test occursin("[1 2; 3 4]", msg) || occursin("Int64[1 2; 3 4]", msg) + @test occursin("([1 2; 3 4])", msg) || occursin("(Int64[1 2; 3 4])", msg) # the printing of Adjoint depends on global state msg = replstr(A')