Skip to content

Commit

Permalink
show for adjtrans
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Jul 14, 2023
1 parent e192a93 commit c4a5d39
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/quasiadjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,24 @@ arguments(::ApplyLayout{typeof(vcat)}, A::QuasiTranspose) = map(transpose, argum
arguments(::ApplyLayout{typeof(hcat)}, A::QuasiTranspose) = map(transpose, arguments(ApplyLayout{typeof(vcat)}(), parent(A)))


copy(M::Mul{ApplyLayout{typeof(vcat)},QuasiArrayLayout}) = vcat((arguments(vcat, M.A) .* Ref(M.B))...)
copy(M::Mul{ApplyLayout{typeof(vcat)},QuasiArrayLayout}) = vcat((arguments(vcat, M.A) .* Ref(M.B))...)

Check warning on line 250 in src/quasiadjtrans.jl

View check run for this annotation

Codecov / codecov/patch

src/quasiadjtrans.jl#L250

Added line #L250 was not covered by tests


###
# show/summary
###

for shw in (:show, :summary)
@eval begin
function $shw(io::IO, Ac::QuasiAdjoint)
print(io, "adjoint(")
$shw(io, parent(Ac))
print(io, ")")
end
function $shw(io::IO, Ac::QuasiTranspose)
print(io, "transpose(")
$shw(io, parent(Ac))
print(io, ")")
end
end
end
10 changes: 9 additions & 1 deletion test/test_quasiadjtrans.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is based on a part of Julia. License is MIT: https://julialang.org/license


using QuasiArrays, Test, LinearAlgebra
using QuasiArrays, Test, Base64, LinearAlgebra
import QuasiArrays: MemoryLayout


Expand Down Expand Up @@ -250,4 +250,12 @@ import QuasiArrays: MemoryLayout
@test MemoryLayout(typeof(A)) == MemoryLayout(typeof(A')) == MemoryLayout(typeof(transpose(A)))
@test QuasiArray(A') == QuasiArray(A.parent',(Base.OneTo(2),[0,0.5]))
end

@testset "show" begin
x = QuasiArray([1,2],[0,0.5])
@test stringmime("text/plain", x') == "adjoint(QuasiVector([1, 2], [0.0, 0.5]))"
@test stringmime("text/plain", transpose(x)) == "transpose(QuasiVector([1, 2], [0.0, 0.5]))"
@test summary(x') == "adjoint(QuasiVector{Int64, Tuple{Vector{Float64}}})"
@test summary(transpose(x)) == "transpose(QuasiVector{Int64, Tuple{Vector{Float64}}})"
end
end

0 comments on commit c4a5d39

Please sign in to comment.