Skip to content

Commit

Permalink
Get test suite passing tests again JuliaData#389
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj authored and Heptazhou committed Apr 9, 2022
1 parent 8777d73 commit 951ab32
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RecipesBase = "0.7,1"
StatsBase = "0.32,0.33"
TextParse = "0.9.1,1"
WeakRefStrings = "0.6"
julia = "1"
julia = "1.3"

[extras]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
1 change: 1 addition & 0 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ function _map_params(f, T, S)
end

_map_params(f, T::Type{Tuple{}},S::Type{Tuple{}}) = ()
_map_params(f, T::Type{NamedTuple{(), Tuple{}}},S::Type{NamedTuple{(), Tuple{}}}) = ()

map_params(f, ::Type{T}, ::Type{S}) where {T,S} = f(T,S)
@inline _tuple_type_head(::Type{T}) where {T<:Tuple} = Base.tuple_type_head(T)
Expand Down
2 changes: 1 addition & 1 deletion test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
@testset "printing" begin
x = distribute(NDSparse([1], [1]), 1)
@test repr(x) == """
1-d Distributed NDSparse with 1 values (Int64) in 1 chunks:
1-d Distributed NDSparse with 1 values ($Int) in 1 chunks:
1 │
──┼──
1 │ 1"""
Expand Down
4 changes: 2 additions & 2 deletions test/test_readwrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
end


path = joinpath(dirname(@__FILE__), "..","test", "sample")
path = joinpath(dirname(pathof(JuliaDB)), "..","test", "sample")
files = glob("*.csv", path)
const spdata_dist = loadndsparse(files, type_detect_rows=4,
indexcols=1:2, usecache=false, chunks=2)
Expand All @@ -41,7 +41,7 @@ const spdata = loadndsparse(files;
distributed=false,
header_exists=true,
indexcols=1:2)
files = glob("*.csv", "sample")
files = glob("*.csv", path)
shuffle_files = shuffle(files)
const spdata_unordered = loadndsparse(shuffle_files;
distributed=false,
Expand Down
10 changes: 5 additions & 5 deletions test/test_table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import JuliaDB: pkeynames, pkeys, excludecols, select, transform
end), t, :x, select=:z) == table([1, 2], [6, 15], names=Symbol[:x, :y])
@test groupreduce(:y => (+), t, :x, select=:z) == table([1, 2], [6, 15], names=Symbol[:x, :y])
x = ndsparse(["a", "b"], [3, 4], chunks=2)
@test (keytype(x), eltype(x)) == (Tuple{String}, Int64)
@test (keytype(x), eltype(x)) == (Tuple{String}, Int)
x = ndsparse((date = Date.(2014:2017),), [4:7;], chunks=2)
@test x[Date("2015-01-01")] == 5
@test (keytype(x), eltype(x)) == (Tuple{Date}, Int64)
@test (keytype(x), eltype(x)) == (Tuple{Date}, Int)
x = ndsparse((["a", "b"], [3, 4]), [5, 6], chunks=2)
@test (keytype(x), eltype(x)) == (Tuple{String,Int64}, Int64)
@test (keytype(x), eltype(x)) == (Tuple{String,Int}, Int)
@test x["a", 3] == 5
x = ndsparse((["a", "b"], [3, 4]), ([5, 6], [7.0, 8.0]), chunks=2)
x = ndsparse((x = ["a", "a", "b"], y = [3, 4, 4]), (p = [5, 6, 7], q = [8.0, 9.0, 10.0]), chunks=2)
@test (keytype(x), eltype(x)) == (Tuple{String,Int64}, NamedTuple{(:p,:q),Tuple{Int64,Float64}})
@test (keytype(x), eltype(x)) == (Tuple{String,Int}, NamedTuple{(:p,:q),Tuple{Int,Float64}})
@test x["a", :] == ndsparse((y = [3, 4],), Columns((p = [5, 6], q = [8.0, 9.0])))
x = ndsparse([1, 2], [3, 4], chunks=2)
@test pkeynames(x) == (1,)
Expand Down Expand Up @@ -223,7 +223,7 @@ import JuliaDB: pkeynames, pkeys, excludecols, select, transform
@test isequal(convertmissing(t, DataValue), t2)
@test isequal(convertmissing(t2, Missing), t)

@test typeof(column(dropmissing(t, :x), :x)) <: Dagger.DArray{Int64,1}
@test typeof(column(dropmissing(t, :x), :x)) <: Dagger.DArray{Int,1}
t = table(["a", "b", "c"], [0.01, 0.05, 0.07], [2, 1, 0], names=[:n, :t, :x], chunks=2)
@test filter((p->p.x / p.t < 100), t) == table(String["b", "c"], [0.05, 0.07], [1, 0], names=Symbol[:n, :t, :x])
x = ndsparse((n = ["a", "b", "c"], t = [0.01, 0.05, 0.07]), [2, 1, 0], chunks=2)
Expand Down

0 comments on commit 951ab32

Please sign in to comment.