diff --git a/docs/make.jl b/docs/make.jl index d15c7f8..2660da6 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,14 +1,14 @@ using Documenter, QueryTables makedocs( - modules = [QueryTables], - sitename = "QueryTables.jl", + modules=[QueryTables], + sitename="QueryTables.jl", analytics="UA-132838790-1", - pages = [ + pages=[ "Introduction" => "index.md" ] ) deploydocs( - repo = "github.com/queryverse/QueryTables.jl.git" + repo="github.com/queryverse/QueryTables.jl.git" ) diff --git a/src/QueryTables.jl b/src/QueryTables.jl index 62d459b..13b68c4 100644 --- a/src/QueryTables.jl +++ b/src/QueryTables.jl @@ -6,15 +6,15 @@ using DataValues export DataTable, NA, isna -struct DataTable{T, TCOLS} <: AbstractVector{T} +struct DataTable{T,TCOLS} <: AbstractVector{T} columns::TCOLS end function fromNT(nt) - nt = map(i->i isa ReadOnlyArrays.ReadOnlyArray ? i : ReadOnlyArrays.ReadOnlyArray(i), nt) + nt = map(i -> i isa ReadOnlyArrays.ReadOnlyArray ? i : ReadOnlyArrays.ReadOnlyArray(i), nt) tx = typeof(nt) - et = NamedTuple{propertynames(nt), Tuple{(eltype(fieldtype(tx, i)) for i in 1:fieldcount(typeof(nt)))...}} - return DataTable{et, typeof(nt)}(nt) + et = NamedTuple{propertynames(nt),Tuple{(eltype(fieldtype(tx, i)) for i in 1:fieldcount(typeof(nt)))...}} + return DataTable{et,typeof(nt)}(nt) end swap_dva_in(A) = A @@ -40,7 +40,7 @@ Base.IndexStyle(::Type{DataTable}) = Base.IndexLinear() function Base.checkbounds(::Type{Bool}, dt::DataTable, i) cols = columns(dt) - if length(cols)==0 + if length(cols) == 0 return true else return checkbounds(Bool, cols[1], i) diff --git a/test/runtests.jl b/test/runtests.jl index 1afe113..3cc7763 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,43 +3,43 @@ using Test @testset "QueryTables" begin -dt1 = DataTable(a=[1,2,3], b=[4.,5.,6.], c=["John", "Sally", "Jim"]) + dt1 = DataTable(a=[1,2,3], b=[4.,5.,6.], c=["John", "Sally", "Jim"]) -@testset "Core" begin + @testset "Core" begin -@test length(dt1) == 3 -@test dt1.a == [1,2,3] -@test dt1.b == [4.,5.,6.] -@test dt1.c == ["John", "Sally", "Jim"] -@test dt1[1] == (a=1, b=4., c="John") -@test dt1[2] == (a=2, b=5., c="Sally") -@test dt1[3] == (a=3, b=6., c="Jim") + @test length(dt1) == 3 + @test dt1.a == [1,2,3] + @test dt1.b == [4.,5.,6.] + @test dt1.c == ["John", "Sally", "Jim"] + @test dt1[1] == (a = 1, b = 4., c = "John") + @test dt1[2] == (a = 2, b = 5., c = "Sally") + @test dt1[3] == (a = 3, b = 6., c = "Jim") -@test collect(dt1) == [(a=1, b=4., c="John"), (a=2, b=5., c="Sally"), (a=3, b=6., c="Jim")] + @test collect(dt1) == [(a = 1, b = 4., c = "John"), (a = 2, b = 5., c = "Sally"), (a = 3, b = 6., c = "Jim")] -dt2 = DataTable([(a=1, b=4., c="John"), (a=2, b=5., c="Sally"), (a=3, b=6., c="Jim")]) + dt2 = DataTable([(a = 1, b = 4., c = "John"), (a = 2, b = 5., c = "Sally"), (a = 3, b = 6., c = "Jim")]) -@test dt1 == dt2 + @test dt1 == dt2 -end + end -@testset "show" begin + @testset "show" begin -@test sprint(show, dt1) == + @test sprint(show, dt1) == "3x3 DataTable\na │ b │ c \n──┼─────┼──────\n1 │ 4.0 │ John \n2 │ 5.0 │ Sally\n3 │ 6.0 │ Jim " -@test sprint((stream,data)->show(stream, "text/plain", data), dt1) == + @test sprint((stream, data) -> show(stream, "text/plain", data), dt1) == "3x3 DataTable\na │ b │ c \n──┼─────┼──────\n1 │ 4.0 │ John \n2 │ 5.0 │ Sally\n3 │ 6.0 │ Jim " -@test sprint((stream,data)->show(stream, "text/html", data), dt1) == + @test sprint((stream, data) -> show(stream, "text/html", data), dt1) == "
a | b | c |
---|---|---|
1 | 4.0 | "John" |
2 | 5.0 | "Sally" |
3 | 6.0 | "Jim" |