Skip to content

Commit 6141a26

Browse files
Format files using DocumentFormat
1 parent 63102b0 commit 6141a26

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Documenter, QueryTables
33
makedocs(
44
modules = [QueryTables],
55
sitename = "QueryTables.jl",
6-
analytics="UA-132838790-1",
6+
analytics = "UA-132838790-1",
77
pages = [
88
"Introduction" => "index.md"
99
]

src/QueryTables.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ using DataValues
66

77
export DataTable, NA, isna
88

9-
struct DataTable{T, TCOLS} <: AbstractVector{T}
9+
struct DataTable{T,TCOLS} <: AbstractVector{T}
1010
columns::TCOLS
1111
end
1212

1313
function fromNT(nt)
1414
nt = map(i->i isa ReadOnlyArrays.ReadOnlyArray ? i : ReadOnlyArrays.ReadOnlyArray(i), nt)
1515
tx = typeof(nt)
16-
et = NamedTuple{propertynames(nt), Tuple{(eltype(fieldtype(tx, i)) for i in 1:fieldcount(typeof(nt)))...}}
17-
return DataTable{et, typeof(nt)}(nt)
16+
et = NamedTuple{propertynames(nt),Tuple{(eltype(fieldtype(tx, i)) for i in 1:fieldcount(typeof(nt)))...}}
17+
return DataTable{et,typeof(nt)}(nt)
1818
end
1919

2020
swap_dva_in(A) = A
2121
swap_dva_in(A::Array{<:DataValue}) = DataValueArray(A)
2222

2323
function DataTable(;cols...)
24-
return fromNT(map(col -> swap_dva_in(col), values(cols)))
24+
return fromNT(map(col->swap_dva_in(col), values(cols)))
2525
end
2626

2727
function DataTable(table)
@@ -40,7 +40,7 @@ Base.IndexStyle(::Type{DataTable}) = Base.IndexLinear()
4040

4141
function Base.checkbounds(::Type{Bool}, dt::DataTable, i)
4242
cols = columns(dt)
43-
if length(cols)==0
43+
if length(cols) == 0
4444
return true
4545
else
4646
return checkbounds(Bool, cols[1], i)
@@ -49,7 +49,7 @@ end
4949

5050
@inline function Base.getindex(dt::DataTable{T}, i::Int) where {T}
5151
@boundscheck checkbounds(dt, i)
52-
return map(col -> @inbounds(getindex(col, i)), columns(dt))
52+
return map(col->@inbounds(getindex(col, i)), columns(dt))
5353
end
5454

5555
function Base.show(io::IO, dt::DataTable)

test/runtests.jl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@ using Test
33

44
@testset "QueryTables" begin
55

6-
dt1 = DataTable(a=[1,2,3], b=[4.,5.,6.], c=["John", "Sally", "Jim"])
6+
dt1 = DataTable(a = [1,2,3], b = [4.,5.,6.], c = ["John", "Sally", "Jim"])
77

8-
@testset "Core" begin
8+
@testset "Core" begin
99

10-
@test length(dt1) == 3
11-
@test dt1.a == [1,2,3]
12-
@test dt1.b == [4.,5.,6.]
13-
@test dt1.c == ["John", "Sally", "Jim"]
14-
@test dt1[1] == (a=1, b=4., c="John")
15-
@test dt1[2] == (a=2, b=5., c="Sally")
16-
@test dt1[3] == (a=3, b=6., c="Jim")
10+
@test length(dt1) == 3
11+
@test dt1.a == [1,2,3]
12+
@test dt1.b == [4.,5.,6.]
13+
@test dt1.c == ["John", "Sally", "Jim"]
14+
@test dt1[1] == (a = 1, b = 4., c = "John")
15+
@test dt1[2] == (a = 2, b = 5., c = "Sally")
16+
@test dt1[3] == (a = 3, b = 6., c = "Jim")
1717

18-
@test collect(dt1) == [(a=1, b=4., c="John"), (a=2, b=5., c="Sally"), (a=3, b=6., c="Jim")]
18+
@test collect(dt1) == [(a = 1, b = 4., c = "John"), (a = 2, b = 5., c = "Sally"), (a = 3, b = 6., c = "Jim")]
1919

20-
dt2 = DataTable([(a=1, b=4., c="John"), (a=2, b=5., c="Sally"), (a=3, b=6., c="Jim")])
20+
dt2 = DataTable([(a = 1, b = 4., c = "John"), (a = 2, b = 5., c = "Sally"), (a = 3, b = 6., c = "Jim")])
2121

22-
@test dt1 == dt2
22+
@test dt1 == dt2
2323

24-
end
24+
end
2525

26-
@testset "show" begin
26+
@testset "show" begin
2727

28-
@test sprint(show, dt1) ==
28+
@test sprint(show, dt1) ==
2929
"3x3 DataTable\na │ b │ c \n──┼─────┼──────\n1 │ 4.0 │ John \n2 │ 5.0 │ Sally\n3 │ 6.0 │ Jim "
3030

31-
@test sprint((stream,data)->show(stream, "text/plain", data), dt1) ==
31+
@test sprint((stream, data)->show(stream, "text/plain", data), dt1) ==
3232
"3x3 DataTable\na │ b │ c \n──┼─────┼──────\n1 │ 4.0 │ John \n2 │ 5.0 │ Sally\n3 │ 6.0 │ Jim "
3333

34-
@test sprint((stream,data)->show(stream, "text/html", data), dt1) ==
34+
@test sprint((stream, data)->show(stream, "text/html", data), dt1) ==
3535
"<table><thead><tr><th>a</th><th>b</th><th>c</th></tr></thead><tbody><tr><td>1</td><td>4.0</td><td>&quot;John&quot;</td></tr><tr><td>2</td><td>5.0</td><td>&quot;Sally&quot;</td></tr><tr><td>3</td><td>6.0</td><td>&quot;Jim&quot;</td></tr></tbody></table>"
3636

37-
@test sprint((stream,data)->show(stream, "application/vnd.dataresource+json", data), dt1) ==
37+
@test sprint((stream, data)->show(stream, "application/vnd.dataresource+json", data), dt1) ==
3838
"{\"schema\":{\"fields\":[{\"name\":\"a\",\"type\":\"integer\"},{\"name\":\"b\",\"type\":\"number\"},{\"name\":\"c\",\"type\":\"string\"}]},\"data\":[{\"a\":1,\"b\":4.0,\"c\":\"John\"},{\"a\":2,\"b\":5.0,\"c\":\"Sally\"},{\"a\":3,\"b\":6.0,\"c\":\"Jim\"}]}"
3939

40-
@test showable("text/html", dt1) == true
41-
@test showable("application/vnd.dataresource+json", dt1) == true
40+
@test showable("text/html", dt1) == true
41+
@test showable("application/vnd.dataresource+json", dt1) == true
4242

43-
end
43+
end
4444

4545
end

0 commit comments

Comments
 (0)