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

closes #784 by fixing typename + tests #786

Merged
merged 5 commits into from
Jun 11, 2022
Merged

closes #784 by fixing typename + tests #786

merged 5 commits into from
Jun 11, 2022

Conversation

tlienart
Copy link
Collaborator

@tlienart tlienart commented Jun 10, 2022

  • fixes typename for DataFrames.DataFrame object, tested with 1.0 to 1.7 seems ok
  • added simple tests for it (required adding DataFrames to the extras)

Note: this isdataframe stuff should eventually be removed via improvements to Tables.jl (see here) but for now is necessary to avoid big bottlenecks.

@tlienart
Copy link
Collaborator Author

thanks for the review @OkonSamuel feel free to take this over, I'm not close enough to the Tables API to know what's best so I trust your choices are better, it might be good to check the tests are right, maybe do a side test with what brought Jack_N to open the issue in the first place and check that there's no bottleneck anymore?

@jackn11
Copy link

jackn11 commented Jun 10, 2022

Thank you both for helping with the changes. Also, it may be a good idea to make the slight modification to the selectcols function so that the '!' is not needed in the if statement. The code is below so you can see what I mean. Removing the unnecessary double negative should help keep the code clean and understandable.

function MMI.selectcols(::FI, ::Val{:table}, X, c::Union{Symbol, Integer})
    if isdataframe(X)
        return X[!, c]
    else
        cols = Tables.columntable(X) # named tuple of vectors
        return cols[c]
    end
end

function MMI.selectcols(::FI, ::Val{:table}, X, c::AbstractArray)
    if isdataframe(X)
        return X[!, c]
    else
        cols = Tables.columntable(X) # named tuple of vectors
        newcols = project(cols, c)
        return Tables.materializer(X)(newcols)
    end
end

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2022

Codecov Report

Merging #786 (ca69c2f) into dev (2257471) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev     #786   +/-   ##
=======================================
  Coverage   85.92%   85.93%           
=======================================
  Files          36       36           
  Lines        3460     3462    +2     
=======================================
+ Hits         2973     2975    +2     
  Misses        487      487           
Impacted Files Coverage Δ
src/interface/data_utils.jl 96.87% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2257471...ca69c2f. Read the comment docs.

Copy link
Member

@ablaom ablaom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OkonSamuel I'm happy with this, modulo my single suggestion. Please merge and tag a new release at your leisure.

@tlienart tlienart merged commit e3e03d4 into dev Jun 11, 2022
@tlienart tlienart deleted the typenamefix branch June 11, 2022 07:50
@tlienart
Copy link
Collaborator Author

I just merged (it was my branch so not sure if sam could do it) will leave the tag & release to you guys

@ablaom ablaom mentioned this pull request Jun 12, 2022
@ablaom
Copy link
Member

ablaom commented Jun 12, 2022

Thank you @tlienart and @OkonSamuel . A new release just tagged.

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 this pull request may close these issues.

5 participants