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

Overload Compat.eachrow and Compat.eachcol #2067

Merged
merged 5 commits into from
Dec 27, 2019

Conversation

tkf
Copy link
Contributor

@tkf tkf commented Dec 26, 2019

As eachrow and eachcol are in Compat.jl JuliaLang/Compat.jl#658, I think it makes sense to overload the functions in Compat.jl rather than creating new functions. What do you think?

I also added a test to make sure that similar overlooks do not happen in the future.

@@ -34,7 +34,7 @@ test = ["DataStructures", "DataValues", "Dates", "Logging", "Random", "Test"]
[compat]
julia = "1"
CategoricalArrays = "0.7"
Compat = "2, 3"
Compat = "2.2, 3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eachrow and eachcol need Compat 2.2: https://github.com/JuliaLang/Compat.jl/releases/tag/v2.2.0

test/runtests.jl Outdated Show resolved Hide resolved
if VERSION >= v"1.1.0-DEV.792"
import Base.eachcol, Base.eachrow
else
if VERSION < v"1.1.0-DEV.792"
Copy link
Member

Choose a reason for hiding this comment

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

Two questions as I do not know Compat.jl well enough:

  • do we have to export something we import via Compat.? (probably yes, but I just wanted to make sure)
  • shoud import Compat. be used even on current versions of Julia or it should be in the if block here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • do we have to export something we import via Compat.?

My understanding is that Compat is "just" a Julia package. So, if you want eachrow to work without explicitly importing Compat, I think you need to re-export eachrow from DataFrames.jl.

  • shoud import Compat. be used even on current versions of Julia or it should be in the if block here.

I don't think it matters since Base.eachrow === Compat.eachrow for julia >= 1.1 and julia does not care how eachrow is imported. But my guess is that it is rather an implementation detail of julia so

if VERSION < v"1.1.0-DEV.792"
    import Base: eachcol, eachrow
else
    import Compat: eachcol, eachrow
end

makes sense if you want to play on the very safe side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed the change I just suggested 9f1d862. Let me know if you want to revert it.

@bkamins
Copy link
Member

bkamins commented Dec 26, 2019

Thank you for the PR. I have left two questions to learn for the future as I do not know Compat.jl well enough.

test/compat.jl Outdated Show resolved Hide resolved
@nalimilan nalimilan merged commit baf2740 into JuliaData:master Dec 27, 2019
@nalimilan
Copy link
Member

Thanks!

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.

3 participants