-
Notifications
You must be signed in to change notification settings - Fork 367
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
Conversation
@@ -34,7 +34,7 @@ test = ["DataStructures", "DataValues", "Dates", "Logging", "Random", "Test"] | |||
[compat] | |||
julia = "1" | |||
CategoricalArrays = "0.7" | |||
Compat = "2, 3" | |||
Compat = "2.2, 3" |
There was a problem hiding this comment.
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
src/DataFrames.jl
Outdated
if VERSION >= v"1.1.0-DEV.792" | ||
import Base.eachcol, Base.eachrow | ||
else | ||
if VERSION < v"1.1.0-DEV.792" |
There was a problem hiding this comment.
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 viaCompat.
? (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 theif
block here.
There was a problem hiding this comment.
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 viaCompat.
?
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 theif
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.
There was a problem hiding this comment.
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.
Thank you for the PR. I have left two questions to learn for the future as I do not know Compat.jl well enough. |
Thanks! |
As
eachrow
andeachcol
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.