Skip to content

Commit 5132df8

Browse files
committed
Simplify showing eval, and add SubArray.
1 parent aee445f commit 5132df8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/abstractarray.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,24 @@ end
5252

5353
## showing
5454

55-
for (atype, op) in
56-
[(:(GPUArray), :(Array)),
57-
(:(LinearAlgebra.Adjoint{<:Any,<:GPUArray}), :(x->LinearAlgebra.adjoint(Array(parent(x))))),
58-
(:(LinearAlgebra.Transpose{<:Any,<:GPUArray}), :(x->LinearAlgebra.transpose(Array(parent(x)))))]
55+
for (AT, f) in
56+
(GPUArray => Array,
57+
LinearAlgebra.Adjoint{<:Any,<:GPUArray} => x->LinearAlgebra.adjoint(Array(parent(x))),
58+
LinearAlgebra.Transpose{<:Any,<:GPUArray} => x->LinearAlgebra.transpose(Array(parent(x))),
59+
SubArray{<:Any,<:Any,<:GPUArray} => x->SubArray(Array(parent(x)), parentindices(x))
60+
)
5961
@eval begin
6062
# for display
61-
Base.print_array(io::IO, X::($atype)) =
62-
Base.print_array(io,($op)(X))
63+
Base.print_array(io::IO, X::$AT) =
64+
Base.print_array(io,$f(X))
6365

6466
# for show
65-
Base._show_nonempty(io::IO, X::($atype), prefix::String) =
66-
Base._show_nonempty(io,($op)(X),prefix)
67-
Base._show_empty(io::IO, X::($atype)) =
68-
Base._show_empty(io,($op)(X))
69-
Base.show_vector(io::IO, v::($atype), args...) =
70-
Base.show_vector(io,($op)(v),args...)
67+
Base._show_nonempty(io::IO, X::$AT, prefix::String) =
68+
Base._show_nonempty(io,$f(X),prefix)
69+
Base._show_empty(io::IO, X::$AT) =
70+
Base._show_empty(io,$f(X))
71+
Base.show_vector(io::IO, v::$AT, args...) =
72+
Base.show_vector(io,$f(v),args...)
7173
end
7274
end
7375

0 commit comments

Comments
 (0)