Skip to content

Problem with nested array types in similar_arr_type #17

@RainerHeintzmann

Description

@RainerHeintzmann
julia> similar_arr_type(typeof(reshape(view(rand(200), 1:100), 1, 100)))
ERROR: MethodError: no method matching Base.ReshapedArray{Float64, 2, SubArray{…}, Tuple{}}(::UndefInitializer, ::Tuple{Int64, Int64})

Closest candidates are:
  (::Type{Base.ReshapedArray{T, N, P, MI}} where {T, N, P<:AbstractArray, MI<:Tuple{Vararg{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}}})(::Any, ::Any, ::Any)
   @ Base reshapedarray.jl:6

Stacktrace:
 [1] similar_arr_type(::Type{Base.ReshapedArray{Float64, 2, SubArray{…}, Tuple{}}}; dims::Int64, dtype::Type)
   @ NDTools C:\Users\pi96doc\.julia\packages\NDTools\Wk0Cg\src\type_tools.jl:85
 [2] similar_arr_type(::Type{Base.ReshapedArray{Float64, 2, SubArray{Float64, 1, Vector{}, Tuple{}, true}, Tuple{}}})
   @ NDTools C:\Users\pi96doc\.julia\packages\NDTools\Wk0Cg\src\type_tools.jl:84ulia> similar_arr_type(typeof(reshape(view(rand(200), 1:100), 1, 100)))
ERROR: MethodError: no method matching Base.ReshapedArray{Float64, 2, SubArray{…}, Tuple{}}(::UndefInitializer, ::Tuple{Int64, Int64})

A similar problem exists for the SubArray type.

julia> similar_arr_type(typeof(view(rand(200), 1:100)))
ERROR: MethodError: no method matching SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}(::UndefInitializer, ::Tuple{Int64})

Closest candidates are:
  SubArray{T, N, P, I, L}(::Any, ::Any, ::Any, ::Any) where {T, N, P, I, L}
   @ Base subarray.jl:19

Stacktrace:
 [1] similar_arr_type(::Type{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}}; dims::Int64, dtype::Type)
   @ NDTools C:\Users\pi96doc\.julia\packages\NDTools\Wk0Cg\src\type_tools.jl:85
 [2] similar_arr_type(::Type{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}})
   @ NDTools C:\Users\pi96doc\.julia\packages\NDTools\Wk0Cg\src\type_tools.jl:84

... will try to fix it by introducing type specializations for these cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions