JuliaArrays / JuliaArrays/StaticArrays.jl

dropdims fails

Open
#1,265 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

This would work if A were a normal matrix:

julia> A = @SMatrix randn(2,2)
2×2 SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
 -0.663672  2.31438
  0.166198  1.26303

julia> dropdims(mean(A; dims=2); dims=2)
ERROR: TypeError: in typeassert, expected Tuple{SOneTo{1}}, got a value of type Tuple{SOneTo{2}}
Stacktrace:
 [1] _dropdims(A::SMatrix{2, 1, Float64, 2}, dims::Tuple{Int64})
   @ Base ./abstractarraymath.jl:92
 [2] _dropdims(A::SMatrix{2, 1, Float64, 2}, dim::Int64)
   @ Base ./abstractarraymath.jl:94
 [3] dropdims(A::SMatrix{2, 1, Float64, 2}; dims::Int64)
   @ Base ./abstractarraymath.jl:82
 [4] top-level scope
   @ REPL[26]: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 issue in the Julia REPL using the shown @SMatrix randn(2,2) and dropdims(mean(A; dims=2); dims=2) call. Compare the result with a normal matrix and inspect the StaticArrays handling around dropdims; done means the call no longer raises the shown TypeError and returns the expected reduced array.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.