mcabbott / mcabbott/AxisKeys.jl

Difficulty writing into array (unsure if intentional)

Open
#75 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

Trying to write into an array gives an error when one of the arrays has a trailing singleton dimension:

julia> table(:, :total) .= sum(pointwise([:loo_score, :naive_score, :overfit]); dims=1)'
ERROR: DimensionMismatch("cannot broadcast array to have fewer dimensions")

Where table(:, :total) and sum(pointwise([:loo_score, :naive_score, :overfit]); dims=1)' return:

1-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓   criterion ∈ 3-element Vector{Symbol}
And data, 3-element view(::Matrix{Float64}, :, 1) with eltype Float64:
 (:loo_score)    2.5e-323
 (:naive_score)  5.0e-323
 (:overfit)      7.4e-323


2-dimensional KeyedArray(NamedDimsArray(...)) with keys:
↓   statistic ∈ 3-element Vector{Symbol}
→   data ∈ 1-element OneTo{Int}
And data, 3×1 adjoint(::Matrix{Float64}) with eltype Float64:
                  (1)
  (:loo_score)     69.38414329944844
  (:naive_score)  218.93276111448398
  (:overfit)      149.54861781503556

This can be left (which would be consistent with Base), or trailing singleton dimensions could be fixed for ease-of-use.

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

Start by reproducing the reported assignment with the shown 1-dimensional and 2-dimensional KeyedArray values, then compare the behavior with Base broadcasting. The issue names no files or tests; completion requires deciding whether trailing singleton dimensions should be normalized or whether the current DimensionMismatch should remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.