Skip to content

real_arr_type not type stable #12

@roflmaostc

Description

@roflmaostc

Where did you need those functions?

julia> real_arr_type(Array{ComplexF64}, dims=2)
Matrix{Float64} (alias for Array{Float64, 2})

julia> real_arr_type(Array{ComplexF64}, dims=3)
Array{Float64, 3}

julia> @code_warntype real_arr_type(Array{ComplexF64}, dims=3)
MethodInstance for (::NDTools.var"#real_arr_type##kw")(::NamedTuple{(:dims,), Tuple{Int64}}, ::typeof(real_arr_type), ::Type{Array{ComplexF64}})
  from (::NDTools.var"#real_arr_type##kw")(::Any, ::typeof(real_arr_type), ::Type{TA}) where TA<:AbstractArray in NDTools at /home/fxw/.julia/dev/NDTools.jl/src/type_tools.jl:27
Static Parameters
  TA = Array{ComplexF64}
Arguments
  _::Core.Const(NDTools.var"#real_arr_type##kw"())
  @_2::NamedTuple{(:dims,), Tuple{Int64}}
  @_3::Core.Const(NDTools.real_arr_type)
  @_4::Type{Array{ComplexF64}}
Locals
  dims::Int64
  @_6::Int64
Body::DataType
1%1  = Base.haskey(@_2, :dims)::Core.Const(true)
│         Core.typeassert(%1, Core.Bool)
│         (@_6 = Base.getindex(@_2, :dims))
└──       goto #3
2 ─       Core.Const(:(@_6 = 1))
3%6  = @_6::Int64
│         (dims = %6)
│   %8  = (:dims,)::Core.Const((:dims,))
│   %9  = Core.apply_type(Core.NamedTuple, %8)::Core.Const(NamedTuple{(:dims,)})
│   %10 = Base.structdiff(@_2, %9)::Core.Const(NamedTuple())
│   %11 = Base.pairs(%10)::Core.Const(Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}())
│   %12 = Base.isempty(%11)::Core.Const(true)
│         Core.typeassert(%12, Core.Bool)
└──       goto #5
4 ─       Core.Const(:(Base.kwerr(@_2, @_3, @_4)))
5%16 = NDTools.:(var"#real_arr_type#2")(dims, @_3, @_4)::DataType
└──       return %16

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