-
Notifications
You must be signed in to change notification settings - Fork 54
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
Type stability of Tables.matrix(::NamedTuple)
#339
Comments
It looks like the source of this instability is here (via Cthulhu) 84 function matrix(table::@NamedTuple{x::Vector{Float64}, y::Vector{Float64}}; transpose::Bool::Bool=false)::Matrix
85 cols::Tables.Columns{@NamedTuple{x::Vector{Float64}, y::Vector{Float64}}} = Columns::Type{Tables.Columns}(table::@NamedTuple{x::Vector{Float64}, y::Vector{Float64}})::Tables.Columns{@NamedTuple{x::Vector{Float64}, y::Vector{Float64}}}
86 types::Tuple{Vararg{DataType}} = schema(cols::Tables.Columns{@NamedTuple{x::Vector{Float64}, y::Vector{Float64}}})::Tables.Schema{(:x, :y), Tuple{Float64, Float64}}.types::Tuple{Vararg{DataType}} So the |
I think the issue is that this function: function Base.getproperty(sch::Schema{names, types}, field::Symbol) where {names, types}
if field === :names
return names === nothing ? getfield(sch, :storednames) : names
elseif field === :types
T = getfield(sch, :storedtypes)
return types === nothing ? (T !== nothing ? T : nothing) : Tuple(fieldtype(types, i) for i = 1:fieldcount(types))
else
throw(ArgumentError("unsupported property for Tables.Schema"))
end
end does not have a type stable return value. |
Fixed in #340! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm descending some type instability issues in my package and realized that
Tables.matrix(::NamedTuple)
is not type stable. Would this be feasible to implement?For example:
So the type inference is not able to infer that this is a
Matrix{Float64}
, only that it is aMatrix{Any}
, despite the method call being specialized to a NamedTuple withVector{Float64}
for columns.Version info:
The text was updated successfully, but these errors were encountered: