Skip to content

Commit

Permalink
Merge branch 'master' into jq/len
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj authored Sep 8, 2017
2 parents 15c3b37 + 0f7c94e commit 0f11789
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/dataframerow/dataframerow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ function Base.isless(r1::DataFrameRow, r2::DataFrameRow)
(size(r1.df, 2) == size(r2.df, 2)) ||
throw(ArgumentError("Rows of the data tables that have different number of columns cannot be compared ($(size(df1, 2)) and $(size(df2, 2)))"))
@inbounds for i in 1:size(r1.df, 2)
isless(r1.df[i][r1.row], r2.df[i][r2.row]) && return true
isequal(r1.df[i][r1.row], r2.df[i][r2.row]) || return false
if !isequal(r1.df[i][r1.row], r2.df[i][r2.row])
return isless(r1.df[i][r1.row], r2.df[i][r2.row])
end
end
return true
return false
end
26 changes: 13 additions & 13 deletions test/dataframerow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ module TestDataFrameRow
df4 = DataFrame(a=[1, 1, 2, 2, 2, 2, null, null],
b=Union{Float64, Null}[2.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0],
c=[:B, null, :A, :C, :D, :D, :A, :A])
@test DataFrameRow(df4, 1) < DataFrameRow(df4, 2)
@test DataFrameRow(df4, 2) > DataFrameRow(df4, 1)
@test DataFrameRow(df4, 1) == DataFrameRow(df4, 1)
@test DataFrameRow(df4, 1) < DataFrameRow(df4, 3)
@test DataFrameRow(df4, 3) > DataFrameRow(df4, 1)
@test DataFrameRow(df4, 3) < DataFrameRow(df4, 4)
@test DataFrameRow(df4, 4) > DataFrameRow(df4, 3)
@test DataFrameRow(df4, 4) < DataFrameRow(df4, 5)
@test DataFrameRow(df4, 5) > DataFrameRow(df4, 4)
@test DataFrameRow(df4, 6) == DataFrameRow(df4, 5)
@test DataFrameRow(df4, 5) == DataFrameRow(df4, 6)
@test DataFrameRow(df4, 7) < DataFrameRow(df4, 8)
@test DataFrameRow(df4, 8) > DataFrameRow(df4, 7)
@test isless(DataFrameRow(df4, 1), DataFrameRow(df4, 2))
@test !isless(DataFrameRow(df4, 2), DataFrameRow(df4, 1))
@test !isless(DataFrameRow(df4, 1), DataFrameRow(df4, 1))
@test isless(DataFrameRow(df4, 1), DataFrameRow(df4, 3))
@test !isless(DataFrameRow(df4, 3), DataFrameRow(df4, 1))
@test isless(DataFrameRow(df4, 3), DataFrameRow(df4, 4))
@test !isless(DataFrameRow(df4, 4), DataFrameRow(df4, 3))
@test isless(DataFrameRow(df4, 4), DataFrameRow(df4, 5))
@test !isless(DataFrameRow(df4, 5), DataFrameRow(df4, 4))
@test !isless(DataFrameRow(df4, 6), DataFrameRow(df4, 5))
@test !isless(DataFrameRow(df4, 5), DataFrameRow(df4, 6))
@test isless(DataFrameRow(df4, 7), DataFrameRow(df4, 8))
@test !isless(DataFrameRow(df4, 8), DataFrameRow(df4, 7))

# hashing
@test hash(DataFrameRow(df, 1)) != hash(DataFrameRow(df, 2))
Expand Down

0 comments on commit 0f11789

Please sign in to comment.