Skip to content

Commit 7919f12

Browse files
committed
handle more linalg wrappers
#69
1 parent 24b89d5 commit 7919f12

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/functions.jl

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ Olist = [ :AbstractMatrix, :AbstractVector, :Number,
294294
:(Transpose{<:Any,<:AbstractMatrix}), :(Transpose{<:Any,<:AbstractVector}),
295295
:(NamedDimsArray{L,T,1} where {L,T}), :(NamedDimsArray{L,T,2} where {L,T}),
296296
:(Adjoint{<:Number,<:AbstractVector}), # 1.5 problem...
297+
:(Diagonal), :(Union{LowerTriangular, UpperTriangular}),
297298
]
298299
for (Ts, Ss) in [(Rlist, Rlist), (Rlist, Olist), (Olist, Rlist)]
299300
for T in Ts, S in Ss # some combinations are errors, later, that's ok

test/_functions.jl

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Test, AxisKeys, Statistics
2+
using NamedDims: unname
23

34
M = wrapdims(rand(Int8, 3,4), r='a':'c', c=2:5)
45
MN = NamedDimsArray(M.data.data, r='a':'c', c=2:5)
@@ -267,6 +268,21 @@ end
267268
@testset "linalg" begin
268269
using LinearAlgebra
269270

271+
# more wrappers -- https://github.com/mcabbott/AxisKeys.jl/issues/69
272+
@testset "wrappers" begin
273+
D3 = Diagonal(randn(3))
274+
U3 = UpperTriangular(rand(3,3))
275+
U4 = UpperTriangular(rand(4,4) .+ im)
276+
277+
@test axiskeys(D3 * unname(M), 2) == 2:5
278+
@test_skip U3 * M # *(::UpperTriangular, ::NamedDimsArray) is ambiguous
279+
@test axiskeys(U4 * unname(M'), 2) == 'a':'c'
280+
281+
@test axiskeys(D3 \ M, 2) == 2:5
282+
@test axiskeys(U3 \ M, 2) == 2:5
283+
@test_skip U4 / M # no method matching ldiv!(::NamedDims.NamedFactorization, ::Matrix{ComplexF64})
284+
end
285+
270286
@testset "cholesky" begin
271287
A = rand(10, 3)
272288
ka = KeyedArray(A, (0:9, ["a", "b", "c"]))

0 commit comments

Comments
 (0)