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

selectcols should handle tuple input #991

Open
MilesCranmer opened this issue Dec 23, 2024 · 2 comments · May be fixed by #992
Open

selectcols should handle tuple input #991

MilesCranmer opened this issue Dec 23, 2024 · 2 comments · May be fixed by #992
Assignees

Comments

@MilesCranmer
Copy link
Contributor

selectcols seems to expect AbstractVector input though sometimes this may not be the output type of schema(...).names:

julia> using MLJBase

julia> import MLJModelInterface as MMI

julia> X = (; x1=ones(3), x2=ones(3), x3=ones(3));

julia> MMI.selectcols(X, MMI.schema(X).names)  # Fails
ERROR: MethodError: no method matching _selectcols(::MLJModelInterface.FullInterface, ::Val{…}, ::@NamedTuple{}, ::Tuple{…})
The function `_selectcols` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  _selectcols(::Union{MLJModelInterface.FullInterface, MLJModelInterface.LightInterface}, ::Val{:other}, ::Any, ::Any)
   @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:381
  _selectcols(::Union{MLJModelInterface.FullInterface, MLJModelInterface.LightInterface}, ::Val{:other}, ::Nothing, ::Any)
   @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:379
  _selectcols(::Union{MLJModelInterface.FullInterface, MLJModelInterface.LightInterface}, ::Val{:other}, ::AbstractMatrix, ::Any)
   @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:377
  ...

Stacktrace:
 [1] selectcols(m::MLJModelInterface.FullInterface, v::Val{…}, X::@NamedTuple{}, r::Tuple{…})
   @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:374
 [2] selectcols(X::@NamedTuple{x1::Vector{…}, x2::Vector{…}, x3::Vector{…}}, c::Tuple{Symbol, Symbol, Symbol})
   @ MLJModelInterface ~/.julia/packages/MLJModelInterface/y9x5A/src/data_utils.jl:370
 [3] top-level scope
   @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> MMI.selectcols(X, collect(MMI.schema(X).names))  # Works
(x1 = [1.0, 1.0, 1.0],
 x2 = [1.0, 1.0, 1.0],
 x3 = [1.0, 1.0, 1.0],)
@ablaom ablaom added bug Something isn't working and removed bug Something isn't working labels Dec 26, 2024
@ablaom
Copy link
Member

ablaom commented Dec 26, 2024

It seems this is needed to avoid type instabilities in some applications, right?

@MilesCranmer
Copy link
Contributor Author

Yeah exactly

@OkonSamuel OkonSamuel self-assigned this Jan 5, 2025
@ablaom ablaom transferred this issue from JuliaAI/MLJModelInterface.jl Jan 5, 2025
ablaom added a commit that referenced this issue Jan 5, 2025
@ablaom ablaom linked a pull request Jan 5, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants