mcabbott / mcabbott/AxisKeys.jl

Could `setindex!` work this way?

Open
#58 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
154
Forks
31
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example with KeyedArray and inspect setindex! in src/struct.jl around line 129. Determine the intended behavior for a[down=1] += b[down=1]; done should be established by a regression test showing whether this keyword-indexed assignment is supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.