Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type assert triggers when calling dropdims with a StaticArray #893

Closed
mroavi opened this issue Apr 13, 2021 · 1 comment
Closed

Comments

@mroavi
Copy link

mroavi commented Apr 13, 2021

Minimal example:

julia> using StaticArrays
julia> arr = @MMatrix rand(Int64,4,1)
4×1 MMatrix{4, 1, Int64, 4} with indices SOneTo(4)×SOneTo(1):
 -1142656121258989149
   636254653156898121
 -4641314833637010406
  -842100514524024656
julia> dropdims(arr, dims=2)
ERROR: TypeError: in typeassert, expected Tuple{SOneTo{1}}, got a value of type Tuple{SOneTo{4}}
Stacktrace:
 [1] _dropdims(A::MMatrix{4, 1, Int64, 4}, dims::Tuple{Int64})
   @ Base ./abstractarraymath.jl:85
 [2] _dropdims(A::MMatrix{4, 1, Int64, 4}, dim::Int64)
   @ Base ./abstractarraymath.jl:87
 [3] dropdims(A::MMatrix{4, 1, Int64, 4}; dims::Int64)
   @ Base ./abstractarraymath.jl:70
 [4] top-level scope
   @ REPL[3]:1

Jakob Nybo Nissen on Slack:

It looks to me like Base's function is wrong - please make an issue!
Specifically, what happens is that the typeassert in reshape(A, d::typeof(_sub(axes(A), dims))) is not right - it picks up the wrong axes. It works by accident for Base arrays since all axes of Base arrays have the same type

@mroavi
Copy link
Author

mroavi commented Apr 13, 2021

Moved to Julia Base JuliaLang/julia#40462

@mroavi mroavi closed this as completed Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant