AxisKeys.jl icon indicating copy to clipboard operation
AxisKeys.jl copied to clipboard

Could `setindex!` work this way?

Open mzgubic opened this issue 4 years ago • 1 comments

a = KeyedArray(rand(2, 3), down=[1, 2], across=[1.0, 2.0, 3.0])
b = KeyedArray(rand(1, 3), down=[1], across=[1.0, 2.0, 3.0])

julia> a[down=1] += b[down=1]
ERROR: MethodError: no method matching setindex!(::KeyedArray{Float64, 2, NamedDimsArray{(:down, :across), Float64, 2, Matrix{Float64}}, Tuple{Vector{Int64}, Vector{Float64}}}, ::KeyedArray{Float64, 1, NamedDimsArray{(:across,), Float64, 1, Vector{Float64}}, Base.RefValue{Vector{Float64}}}; down=1)
Closest candidates are:
  setindex!(::KeyedArray, ::Any, ::Any...) at /Users/mzgubic/.julia/packages/AxisKeys/G3Okw/src/struct.jl:129 got unsupported keyword argument "down"
  setindex!(::AbstractArray, ::Any, ::Any...) at abstractarray.jl:1264 got unsupported keyword argument "down"
Stacktrace:
 [1] top-level scope
   @ REPL[23]:1

mzgubic avatar Apr 14 '21 14:04 mzgubic

Yes I think that should work, as should a[down=1] .+= b[down=1]. But they don't, both are bugs I think.

mcabbott avatar Apr 14 '21 14:04 mcabbott