diff --git a/Project.toml b/Project.toml index a298945..14219bf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MetidaBase" uuid = "075456b7-4006-432f-9324-2f8453996c49" authors = ["PharmCat and contributors"] -version = "0.11.2" +version = "0.11.3" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" diff --git a/src/dataset.jl b/src/dataset.jl index 00140fb..a7040c6 100644 --- a/src/dataset.jl +++ b/src/dataset.jl @@ -9,7 +9,7 @@ function getdata(d::DataSet) d.ds end -@inline function getindormiss(d::Dict{K}, i::K) where K +@inline function getindormiss(d::AbstractDict{K}, i::K) where K if haskey(d, i) return d[i] end missing end @@ -81,7 +81,7 @@ end ################################################################################ # sort! ################################################################################ -function islessdict(a::Dict{A1,A2}, b::Dict{B1,B2}, k::Union{AbstractVector, Set}) where A1 where A2 where B1 where B2 +function islessdict(a::AbstractDict{A1,A2}, b::AbstractDict{B1,B2}, k::Union{AbstractVector, Set}) where A1 where A2 where B1 where B2 l = length(k) av = Vector{Union{Missing, A2}}(undef, l) bv = Vector{Union{Missing, B2}}(undef, l) @@ -91,7 +91,7 @@ function islessdict(a::Dict{A1,A2}, b::Dict{B1,B2}, k::Union{AbstractVector, Set end isless(av, bv) end -function islessdict(a::Dict, b::Dict, k) +function islessdict(a::AbstractDict, b::AbstractDict, k) isless(getindormiss(a, k), getindormiss(b, k)) end function Base.sort!(d::DataSet{T}, k; alg::Base.Algorithm = QuickSort, lt=nothing, by=nothing, rev::Bool=false, order::Base.Ordering = Base.Forward) where T <: Union{AbstractIdData, AbstractIDResult} diff --git a/test/runtests.jl b/test/runtests.jl index 928aca4..51cab84 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -91,6 +91,9 @@ using Test, Tables, TypedTables, DataFrames, CSV end exidds = MetidaBase.DataSet(exiddsv) ############################################################################ + @test Tables.istable(exidds) == false + @test Tables.rowaccess(exidds) == false + ############################################################################ item = ExampleIDStruct(Dict(:c => 6, :j => 6)) ds1 = deepcopy(exidds) ds2 = deepcopy(exidds) @@ -123,6 +126,11 @@ using Test, Tables, TypedTables, DataFrames, CSV @test exrsds[1, :r1] == 3 @test MetidaBase.getid(exidds[3], :a) == 2 + + dsr = exrsds[1:2] + @test length(dsr) == 2 + @test exrsds[1] === dsr[1] + @test exrsds[2] === dsr[2] ###################################################################### # SORT ######################################################################