From 56abe600342634ddb2127035b72c3decf04835f4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2020 06:49:08 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 8 +++---- src/FeatherFiles.jl | 8 +++---- src/missing-conversion.jl | 8 +++---- test/runtests.jl | 46 +++++++++++++++++++-------------------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 116756a..ae12271 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,14 +1,14 @@ using Documenter, FeatherFiles makedocs( - modules = [FeatherFiles], - sitename = "FeatherFiles.jl", + modules=[FeatherFiles], + sitename="FeatherFiles.jl", analytics="UA-132838790-1", - pages = [ + pages=[ "Introduction" => "index.md" ] ) deploydocs( - repo = "github.com/queryverse/FeatherFiles.jl.git" + repo="github.com/queryverse/FeatherFiles.jl.git" ) diff --git a/src/FeatherFiles.jl b/src/FeatherFiles.jl index 51d8694..07ac3b7 100644 --- a/src/FeatherFiles.jl +++ b/src/FeatherFiles.jl @@ -40,7 +40,7 @@ TableTraits.supports_get_columns_copy_using_missing(x::FeatherFile) = true function IteratorInterfaceExtensions.getiterator(file::FeatherFile) rs = featherread(file.filename) - for i=1:length(rs.columns) + for i = 1:length(rs.columns) col_eltype = eltype(rs.columns[i]) if isa(col_eltype, Union) && col_eltype.b <: Missing T = DataValueArrowVector{col_eltype.a,typeof(rs.columns[i])} @@ -70,8 +70,8 @@ end # end function TableTraits.get_columns_copy_using_missing(file::FeatherFile) - rs = featherread(file.filename) - return NamedTuple{(Symbol.(rs.names)...,)}(((convert(Vector{eltype(c)}, c) for c in rs.columns)...,)) + rs = featherread(file.filename) + return NamedTuple{(Symbol.(rs.names)...,)}(((convert(Vector{eltype(c)}, c) for c in rs.columns)...,)) end function fileio_save(f::FileIO.File{FileIO.format"Feather"}, data) @@ -81,7 +81,7 @@ function fileio_save(f::FileIO.File{FileIO.format"Feather"}, data) columns = Any[c for c in columns] - for i=1:length(columns) + for i = 1:length(columns) if eltype(columns[i]) <: DataValue T = MissingDataValueVector{eltype(eltype(columns[i])),typeof(columns[i])} columns[i] = T(columns[i]) diff --git a/src/missing-conversion.jl b/src/missing-conversion.jl index 6b4bd7c..2f53378 100644 --- a/src/missing-conversion.jl +++ b/src/missing-conversion.jl @@ -1,4 +1,4 @@ -struct DataValueArrowVector{J,T<:Arrow.ArrowVector{Union{J,Missing}}} <: AbstractVector{DataValue{J}} +struct DataValueArrowVector{J,T <: Arrow.ArrowVector{Union{J,Missing}}} <: AbstractVector{DataValue{J}} data::T end @@ -10,9 +10,9 @@ Base.size(A::DataValueArrowVector) = size(A.data) o end -@inline function Base.getindex(A::DataValueArrowVector{J,T}, i) where {J,T<:Arrow.DictEncoding{Union{Missing,J}}} +@inline function Base.getindex(A::DataValueArrowVector{J,T}, i) where {J,T <: Arrow.DictEncoding{Union{Missing,J}}} @boundscheck checkbounds(A.data, i) - @inbounds o = Arrow.unsafe_isnull(A.data, i) ? DataValue{J}() : DataValue{J}(A.data.pool[A.data.refs[i]+1]) + @inbounds o = Arrow.unsafe_isnull(A.data, i) ? DataValue{J}() : DataValue{J}(A.data.pool[A.data.refs[i] + 1]) o end @@ -20,7 +20,7 @@ Base.IndexStyle(::Type{<:DataValueArrowVector}) = IndexLinear() Base.eltype(::Type{DataValueArrowVector{J,T}}) where {J,T} = DataValue{J} -struct MissingDataValueVector{J,T<:AbstractVector{DataValue{J}}} <: AbstractVector{Union{J,Missing}} +struct MissingDataValueVector{J,T <: AbstractVector{DataValue{J}}} <: AbstractVector{Union{J,Missing}} data::T end diff --git a/test/runtests.jl b/test/runtests.jl index 2430c7b..6091b06 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,35 +8,35 @@ using QueryTables @testset "FeatherFiles" begin -source = [(Name="John", Age=34., Children=2), - (Name="Sally", Age=54., Children=1), - (Name="Jim", Age=34., Children=0)] + source = [(Name = "John", Age = 34., Children = 2), + (Name = "Sally", Age = 54., Children = 1), + (Name = "Jim", Age = 34., Children = 0)] -output_filename = tempname() * ".feather" + output_filename = tempname() * ".feather" -source |> save(output_filename) + source |> save(output_filename) -try - sink = load(output_filename) |> IteratorInterfaceExtensions.getiterator |> collect + try + sink = load(output_filename) |> IteratorInterfaceExtensions.getiterator |> collect - @test source == sink + @test source == sink - featherfile = load(output_filename) + featherfile = load(output_filename) - @test IteratorInterfaceExtensions.isiterable(featherfile) == true - @test TableTraits.isiterabletable(featherfile) == true - @test TableTraits.supports_get_columns_copy_using_missing(featherfile) == true - ff_as_cols = TableTraits.get_columns_copy_using_missing(featherfile) - @test ff_as_cols == (Name=["John", "Sally", "Jim"], Age=[34., 54., 34.], Children=[2,1,0]) -finally + @test IteratorInterfaceExtensions.isiterable(featherfile) == true + @test TableTraits.isiterabletable(featherfile) == true + @test TableTraits.supports_get_columns_copy_using_missing(featherfile) == true + ff_as_cols = TableTraits.get_columns_copy_using_missing(featherfile) + @test ff_as_cols == (Name = ["John", "Sally", "Jim"], Age = [34., 54., 34.], Children = [2,1,0]) + finally GC.gc() GC.gc() # rm(output_filename) end -source2 = [(Name=DataValue("John"), Age=DataValue(34.), Children=DataValue{Int}()), - (Name=DataValue("Sally"), Age=DataValue{Float64}(), Children=DataValue(1)), - (Name=DataValue{String}(), Age=DataValue(34.), Children=DataValue(0))] +source2 = [(Name = DataValue("John"), Age = DataValue(34.), Children = DataValue{Int}()), + (Name = DataValue("Sally"), Age = DataValue{Float64}(), Children = DataValue(1)), + (Name = DataValue{String}(), Age = DataValue(34.), Children = DataValue(0))] output_filename2 = tempname() * ".feather" @@ -51,17 +51,17 @@ try @test IteratorInterfaceExtensions.isiterable(featherfile) == true @test TableTraits.supports_get_columns_copy_using_missing(featherfile) == true ff_as_cols = TableTraits.get_columns_copy_using_missing(featherfile) - @test isequal(ff_as_cols, (Name=["John", "Sally", missing], Age=[34., missing, 34.], Children=[missing,1,0])) + @test isequal(ff_as_cols, (Name = ["John", "Sally", missing], Age = [34., missing, 34.], Children = [missing,1,0])) finally GC.gc() GC.gc() # rm(output_filename2) -end + end ar = load(output_filename2) -@test sprint((stream,data)->show(stream, "text/html", data), ar) == "
NameAgeChildren
"John"34.0#NA
"Sally"#NA1
#NA34.00
" -@test sprint((stream,data)->show(stream, "application/vnd.dataresource+json", data), ar) == "{\"schema\":{\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"number\"},{\"name\":\"Children\",\"type\":\"integer\"}]},\"data\":[{\"Name\":\"John\",\"Age\":34.0,\"Children\":null},{\"Name\":\"Sally\",\"Age\":null,\"Children\":1},{\"Name\":null,\"Age\":34.0,\"Children\":0}]}" +@test sprint((stream, data) -> show(stream, "text/html", data), ar) == "
NameAgeChildren
"John"34.0#NA
"Sally"#NA1
#NA34.00
" +@test sprint((stream, data) -> show(stream, "application/vnd.dataresource+json", data), ar) == "{\"schema\":{\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"number\"},{\"name\":\"Children\",\"type\":\"integer\"}]},\"data\":[{\"Name\":\"John\",\"Age\":34.0,\"Children\":null},{\"Name\":\"Sally\",\"Age\":null,\"Children\":1},{\"Name\":null,\"Age\":34.0,\"Children\":0}]}" @test sprint(show, ar) == "3x3 Feather file\nName │ Age │ Children\n────────┼──────┼─────────\n\"John\" │ 34.0 │ #NA \n\"Sally\" │ #NA │ 1 \n#NA │ 34.0 │ 0 " @test showable("text/html", ar) == true @test showable("application/vnd.dataresource+json", ar) == true @@ -93,7 +93,7 @@ v2 = FeatherFiles.DataValueArrowVector(DictEncoding(["fire", "walk", "with", mis v3 = FeatherFiles.MissingDataValueVector([DataValue{Int64}(), DataValue{Int64}(18), DataValue{Int64}(54)]) @test getindex(v3, 2) == 18 -@test getindex(v3, 1) === missing + @test getindex(v3, 1) === missing @test IndexStyle(v3) == IndexLinear() end \ No newline at end of file