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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

DataAPI = "1.0.1"
InvertedIndices = "1"
IteratorInterfaceExtensions = "0.1.1, 1"
Expand Down
8 changes: 4 additions & 4 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ using Reexport, SortingAlgorithms, Compat, Unicode, PooledArrays, DataAPI
using Base.Sort, Base.Order, Base.Iterators
using Tables, TableTraits, IteratorInterfaceExtensions

import DataAPI.All,
import Compat.eachcol,
Compat.eachrow,
DataAPI.All,
DataAPI.Between,
DataAPI.describe,
Tables.columnindex,
Expand Down Expand Up @@ -50,9 +52,7 @@ export AbstractDataFrame,
unique!,
unstack

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.

export eachcol, eachrow
end

Expand Down
12 changes: 12 additions & 0 deletions test/compat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module TestCompat
tkf marked this conversation as resolved.
Show resolved Hide resolved

import Compat, DataFrames
using Test

@testset "overload Compat functions" begin
@testset "DataFrames.$f === Compat.$f" for f in intersect(names(DataFrames), names(Compat))
@test getproperty(DataFrames, f) === getproperty(Compat, f)
end
end

end # module
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ my_tests = ["utils.jl",
"tabletraits.jl",
"indexing.jl",
"broadcasting.jl",
"compat.jl",
"deprecated.jl"]

println("Running tests:")
Expand Down