-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LinAlg between Triangular and KeyedArray is ambiguous #69
Comments
Dispatch is tricky... it would be possible to add more methods here to catch this: I wish there was a better approach though. For scalars, Base has clever Note that NamedDims isn't handling this at all:
The reason that has names is that it calls
|
Just adding that this is also the case for julia> Diagonal(rand(3,)) \ KeyedArray(rand(3,), features=[:a, :b, :c]);
ERROR: MethodError: \(::Diagonal{Float64, Vector{Float64}}, ::KeyedArray{Float64, 1, NamedDimsArray{(:features,), Float64, 1, Vector{Float64}}, Base.RefValue{Vector{Symbol}}}) is ambiguous. Candidates:
\(x::AbstractMatrix{T} where T, y::KeyedArray{T, 1, AT, RT} where {T<:Number, AT, RT}) in AxisKeys at /Users/bencottier/.julia/packages/AxisKeys/MhCtB/src/functions.jl:302
\(x::AbstractMatrix{T} where T, y::KeyedArray{T, 1, AT, RT} where {T, AT, RT}) in AxisKeys at /Users/bencottier/.julia/packages/AxisKeys/MhCtB/src/functions.jl:302
\(D::Diagonal, b::AbstractVector{T} where T) in LinearAlgebra at /Applications/Julia-1.6.app/Contents/Resources/julia/share/julia/stdlib/v1.6/LinearAlgebra/src/diagonal.jl:627
Possible fix, define
\(::Diagonal, ::KeyedArray{T, 1, AT, RT} where {T<:Number, AT, RT})
Stacktrace:
[1] top-level scope
@ REPL[16]:1 |
Maybe we should add a few more cases if they are useful? I think the long-term solution is (1) to upgrade LinearAlgebra to work with OffsetArrays, by propagating axes(A) not size(A) every time, and (2) then do #6 so that these hold this package's information. The information is per-axis, so I think trying to re-arrange more things to dispatch on axes, not on whole arrays, would simplify matters. |
NamedDims.jl has a macro for delcaring overloads for It would be nice to deal with this, it is causing many problems right now. It is a general struggle for wrapper arrays, and why people don't love the solution. |
I have added a few more methods in 7919f12 , so the examples on this page should (I think) now work. We are up to 180 methods now for
|
Thanks @mcabbott, the most recent tag has resolved these issues but in the process revealed another one to do with multiplying a KeyedVector by an adjoint.
I gave it a shot at fixing it in #90 but I'm not sure if this is the best way to do it. |
NamedDimsArray
works nicely with triangular matrices butKeyedArray
gives an error:The text was updated successfully, but these errors were encountered: