Repository: invenia/NamedDims.jl (julia)

Issue:
`Adjoint{VariableRef} * NamedDimsArray` breaks
```julia
julia> using NamedDims

julia> using JuMP

julia> m = Model();

julia> x = rand(5);

julia> nda = NamedDimsArray{(:a,)}(x);

julia> z = @variable(m, [1:5]);

julia> z' * x # works
0.262369216144402 _[1] + 0.5685890754024013 _[2] + 0.20130403647700346 _[3] + 0.2260366062767406 _[4] + 0.6009129347889277 _[5]

julia> z' * nda # breaks
ERROR: MethodError: *(::LinearAlgebra.Adjoint{VariableRef, Vector{VariableRef}}, ::NamedDimsArray{(:a,), Float64, 1, Vector{Float64}}) is ambiguous. Candidates:
  *(u::Union{LinearAlgebra.Adjoint{T, var"#s859"}, LinearAlgebra.Transpose{T, var"#s859"}} where {T, var"#s859"<:(AbstractVector)}, v::AbstractVector) in LinearAlgebra at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/LinearAlgebra/src/adjtrans.jl:293
  *(a::AbstractMatrix, b::NamedDimsArray{var"#s3", var"#s2", 1, A} where {var"#s3", var"#s2", A<:AbstractVector{var"#s2"}}) in NamedDims at /Users/mzgubic/.julia/packages/NamedDims/HvlfO/src/functions_math.jl:86
Possible fix, define
  *(::Union{LinearAlgebra.Adjoint{T, var"#s859"}, LinearAlgebra.Transpose{T, var"#s859"}} where {T, var"#s859"<:(AbstractVector)}, ::NamedDimsArray{var"#s3", var"#s2", 1, A} where {var"#s3", var"#s2", A<:AbstractVector{var"#s2"}})
Stacktrace:
 [1] top-level scope
   @ REPL[28]:1

julia> x' * z # works
0.262369216144402 _[1] + 0.5685890754024013 _[2] + 0.20130403647700346 _[3] + 0.2260366062767406 _[4] + 0.6009129347889277 _[5]

julia> nda' * z # works
0.262369216144402 _[1] + 0.5685890754024013 _[2] + 0.20130403647700346 _[3] + 0.2260366062767406 _[4] + 0.6009129347889277 _[5]
```

Pull request description:
Closes #198

Patch:
diff --git a/Project.toml b/Project.toml
index 581ff39..daec6f6 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "NamedDims"
 uuid = "356022a1-0364-5f58-8944-0da4b18d706f"
 authors = ["Invenia Technical Computing Corporation"]
-version = "0.2.48"
+version = "0.2.49"
 
 [deps]
 AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
diff --git a/src/functions_math.jl b/src/functions_math.jl
index 686c121..a81041d 100644
--- a/src/functions_math.jl
+++ b/src/functions_math.jl
@@ -52,8 +52,10 @@ end
 # Using `CoVector` results in Method ambiguities; have to define more specific methods.
 for A in (
     Adjoint{<:Number,<:AbstractVector},
+    Adjoint{<:Any,<:AbstractVector}, # https://github.com/invenia/NamedDims.jl/issues/198
+    Transpose{<:Any,<:AbstractVector}, # https://github.com/invenia/NamedDims.jl/issues/198
     Transpose{<:Real,<:AbstractVector{<:Real}},
-    Transpose{<:Any, <:AbstractMatrix{T}} where T,  # resolves ambiguity error in AxisKeys
+    Transpose{<:Any,<:AbstractMatrix{T}} where {T},  # resolves ambiguity error in AxisKeys
 )
     @eval function Base.:*(a::$A, b::NamedDimsArray{L,T,1,<:AbstractVector{T}}) where {L,T}
         return *(a, parent(b))


Test patch:
diff --git a/test/functions_math.jl b/test/functions_math.jl
index ace9fd1..8939ff2 100644
--- a/test/functions_math.jl
+++ b/test/functions_math.jl
@@ -150,6 +150,8 @@ end
         @test ndv' * ndv == adjoint(v) * ndv == transpose(v) * ndv
         @test ndv * v' == ndv * adjoint(v) == ndv * transpose(v)
         @test ndv * ndv' == [1 2 3; 2 4 6; 3 6 9]
+        VERSION >= v"1.5" && @test adjoint([missing, missing, missing]) * ndv isa Missing # https://github.com/invenia/NamedDims.jl/issues/198
+        @test transpose([missing, missing, missing]) * ndv isa Missing # https://github.com/invenia/NamedDims.jl/issues/198
 
         ndv2 = NamedDimsArray{(:b,)}([3, 2, 1])
         @test_throws DimensionMismatch ndv' * ndv2